Shop OBEX P1 Docs P2 Docs Learn Events
LabVIEW and Propeller Robot Controller — Parallax Forums

LabVIEW and Propeller Robot Controller

maldridgemaldridge Posts: 37
edited 2012-04-18 19:12 in Propeller 1
I am on a very tight time-table and so any help is appreciated.

I am using a propeller based servo controller to control the following items:
  • 4 Drive Victor Motor Controllers (PWM)
  • 4 Spike Relays (2 Pin Digital)
  • 2 Pilot assisted pneumatic solenoids (1 Pin Digital)
  • 2 Servos
I am using labview to gather the data and send it, and I would greatly appreciate any help in working out the spin end of things. For example, I am sending 6 Bytes, describing the PWM state, and then 2 more bytes describing the digital state. What I am having trouble working out is how to decode this on the other end. And, once I have it decoded, how to use it. I understand that I will need to load the serial, then likely two copies of the servo library, but a push in the right direction would be greatly appreciated.

Thanks in advance.

Comments

  • StephenMooreStephenMoore Posts: 188
    edited 2012-04-13 22:01
    What do you need LabView for?

    Let the Prop do it all.

    However, you are probably going to interface right through the Prop USB port using a COM on the PC so you need to allocate a data structure on the PC side and reserve similar data format in memory on the Prop. Two cogs will handle all of this using FullDuplexSerial and your data handler routine.

    Just how you read and set your PWM routines for the Victors may be a little different than the Servos so be careful there.

    Sounds like a lot of fun!

    sm
  • maldridgemaldridge Posts: 37
    edited 2012-04-14 08:47
    I need labview and a PC because I have to have a USB host. I am building this as a robot controller for a class to use. Essentially, there is a PC and a board with all the high voltage stuff on it, and the robots are connected through tethers. Students will drive thier robots using USB gamepads, which replace the more vulnerable IFI system we have currently. In labview I have my datatype set up so that it sends 1 header byte, 6 bytes for speed/servo control and 2 more bytes for switching the relays and solenoid.

    The person I spoke with at NI said that it was simple serial, and that if I could just read in the data by knowing how many bytes to look for, that would work. That is where I hit the brick wall of not knowing how to deal with the input on the other side. For example, I know that in pbasic, I could use the serin command and just supply it with my variables, but I don't know how to do that with spin.

    Thanks for the speedy reply.
  • StephenMooreStephenMoore Posts: 188
    edited 2012-04-14 12:27
    The counter part to SERIN is FullDuplexSrial.rx
    The counterpart to SEROUT is FullDuplexSerial.tx

    e.g.
    CON     _clkmode = xtal1 + pll16x
            _xinfreq = 5_000_000
    
    
    VAR
            byte      myCharArray[6]
    
    
    OBJ
            comm: "FullDuplexSerial"
    
    
    PUB     myComm | idx
    
    
            comm.Start(31,30,0,115200)           ' start serial communication driver
      repeat
            repeat while comm.rxcheck == -1      ' wait for a byte to be received
    
    
            repeat idx from 0 to 5               ' read the entire packet into my data type
             myCharArray[idx] := comm.rx
    
    
            repeat idx from 0 to 5               ' echo the entire message back
             comm.tx(myCharArray[idx])  
    
    
    
    
  • maldridgemaldridge Posts: 37
    edited 2012-04-16 18:09
    hmm, I had problems where that was eating bytes, and I redefined the way my serial protocol works, so this is what I eventually came up with.
    'Bert Field Controller'Written by: Michael Aldridge
    '            with much assistance from Carlos Gross Jones
    'Date Modified: 4.14.12
    
    
    CON
      _clkmode = xtal1 + pll16x
      _xinfreq = 5_000_000
    
    
    VAR
      byte P1VIC1
      byte P1VIC2
      byte P1SERV
      byte P1RLY1
      byte P1RLY2
      byte P1PNUE
    
    
      byte P2VIC1
      byte P2VIC2
      byte P2SERV
      byte P2RLY1
      byte P2RLY2
      byte P2PNUE
    
    
    
    
    OBJ
      link  : "FullDuplexSerial"
    
    
    
    
    PUB Main
    link.start(31, 30, 0, 115200)
    
    
    repeat
      link.str(string("ready to receive",13))
      serWait
      acquireData
      convertVals                                
    
    
    PUB serWait
       repeat while 1
            repeat while NOT (link.rx == 65)
            link.str(string("first char correct",13))
            if link.rx == 65
              link.str(string("second char correct",13))
              return
            else
              next
              
    
    
    PUB acquireData
      
    P1VIC1:=link.rx
    P1VIC2:=link.rx
    P1SERV:=link.rx
    P1RLY1:=link.rx
    P1RLY2:=link.rx
    P1PNUE:=link.rx
    
    
    P2VIC1:=link.rx
    P2VIC2:=link.rx
    P2SERV:=link.rx
    P2RLY1:=link.rx
    P2RLY2:=link.rx
    P2PNUE:=link.rx
    link.str(String("PACKET RECIEVED",13))
             
    
    
    PRI convertVals
    
    
    P1VIC1:=P1VIC1-127
    P1VIC2:=P1VIC2-127
    P1SERV:=P1SERV-127
    
    
    P2VIC1:=P2VIC1-127
    P2VIC2:=P2VIC2-127
    P2SERV:=P2SERV-127
    

    now to just write the PWM code...
  • StephenMooreStephenMoore Posts: 188
    edited 2012-04-16 22:18
    You may want to consider changing the baud rate if LabView can't keep up. Otherwise you are on your way. Spin is a great language and the Prop is a very powerful chip.
  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2012-04-17 06:56
    For PWM, I highly recommend PhiPi's PWMx8 object.
  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2012-04-17 07:00
    Actually, you may want to look at Victor 88x Speed Controller Driver and Servo32v7.
  • maldridgemaldridge Posts: 37
    edited 2012-04-18 19:12
    I wound up using the servo library, it did pretty much exactly what I wanted, but now I am having problems with the relays. For those of you that are familiar with them, I am using SPIKE relays from IFI. They are driven by two pins in different combinations of on and off to get two directions, off, and both terminals at V+.

    Here is where it gets weird, on my protoboard where I have a dip plus kit, it works fine (with LED's, the SPIKE is at school right now), but on the board I intend to use, a servo controller board, it does all kinds of weird things such as oscillating states, wrong output configuration and other things that are seemingly random.

    Any ideas?

    EDIT:
    alright, I have tracked down the oscillating state to a bad connection, but now I have a problem where it will just turn on all pins at once, instead of the one I write the logical state to. Any ideas?
Sign In or Register to comment.