Shop OBEX P1 Docs P2 Docs Learn Events
Question:Trying to figure out code for R/C Transmitter to Prop chip using prob basic? — Parallax Forums

Question:Trying to figure out code for R/C Transmitter to Prop chip using prob basic?

cazman128cazman128 Posts: 25
edited 2011-05-12 20:04 in Propeller 1
Hello, im working on a senior project and need help with code, i am writing in prob basic. I want to use three channels on a R/C transmitter to power two motors through H-Bridges. Two channels will be fore the two motors and the third channel with be the channel 5 swtich and is for the Enable on the h-bridges. I am having lots of trouble writing code from the transmitter to the prop board in prob-basic and into the h-bridges. The two channels will control one motor each through their own seperate h-bridges.

I know that my transmitter is set up as follows:

1.1-1.44 = "Low"
1.45-1.55 = "Dead Zone"
1.56/1.91 = "High"

The trouble im having is the initial pulse in code to prop inputs and then into ouputs for the h-brigdges. The wiring is easy, just need help on the code.

Thanks for the help..

Chris..

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2011-05-04 16:46
    You have to post your code. Use the "Manage Attachments" button which can upload your source file(s). If you haven't commented your code, this might be a good time to include comments about how things are connected and what each section of code is doing (at a minimum).
  • cazman128cazman128 Posts: 25
    edited 2011-05-04 16:49
    Mike Green wrote: »
    You have to post your code. Use the "Go Advanced" button to invoke the Attachment Manager which can upload your source file(s). If you haven't commented your code, this might be a good time to include comments about how things are connected and what each section of code is doing (at a minimum).

    Hello, thats the thing, i used a basic stamp for a year and a half so im not to to familiar with prob basic, im actually having trouble starting the code, reagarding pulsein and such..
  • Mike GreenMike Green Posts: 23,101
    edited 2011-05-04 16:58
    For things like PULSIN, you should start with the "BS2 Functions" object in the Object Exchange. There are SPIN methods that provide the functional equivalents of most of the Stamp I/O statements like PULSIN. You should be able to translate them into PropBasic. They're not very complicated. Have a look at that. There are some other objects in the Object Exchange that handle receiving R/C control signals and controlling H-Bridges. Have a look at those as well. You may find that it's easier to just use Spin and these objects.
  • cazman128cazman128 Posts: 25
    edited 2011-05-04 17:07
    hmmm okk...Thanks! ill have to give it a shot tomorrow..
  • cazman128cazman128 Posts: 25
    edited 2011-05-04 17:27
    Mike Green wrote: »
    For things like PULSIN, you should start with the "BS2 Functions" object in the Object Exchange. There are SPIN methods that provide the functional equivalents of most of the Stamp I/O statements like PULSIN. You should be able to translate them into PropBasic. They're not very complicated. Have a look at that. There are some other objects in the Object Exchange that handle receiving R/C control signals and controlling H-Bridges. Have a look at those as well. You may find that it's easier to just use Spin and these objects.

    Do you know of any code out there i can use as a guide, im on the object exchange and having alot of trouble
  • Mike GreenMike Green Posts: 23,101
    edited 2011-05-04 17:45
    The top "sticky thread" on this forum is a good introduction to the Propeller (here).
  • bennettdanbennettdan Posts: 614
    edited 2011-05-04 19:01
    cazman128,
    What type of H bridges are you controlling RC speed controllers or a custom made one?
    Look at these I found in the obex
    http://obex.parallax.com/objects/522/
    http://obex.parallax.com/objects/592/
    http://obex.parallax.com/objects/401/
  • JasonDorieJasonDorie Posts: 1,930
    edited 2011-05-05 00:06
    I'm not familiar with PropBasic, but there's an object in Spin / PASM that will read the pulses from a receiver and turn them into microsecond values you can use. I don't believe it's in the Obex, but the original post for it is here: http://forums.parallax.com/showthread.php?99010-RC-Receiver-pulse-reader
  • cazman128cazman128 Posts: 25
    edited 2011-05-07 22:41
    JasonDorie wrote: »
    I'm not familiar with PropBasic, but there's an object in Spin / PASM that will read the pulses from a receiver and turn them into microsecond values you can use. I don't believe it's in the Obex, but the original post for it is here: http://forums.parallax.com/showthread.php?99010-RC-Receiver-pulse-reader

    Hello, the only problem is i am writing in propbasic, i dnt have the time to learn spin. i have started the code, just having some trouble here and there with the IF statements because i have to learn hoiw to say something like...

    if X > 1.1 ms and < 1.45 then FORWARD:
    this is where im hung upp
  • simonlsimonl Posts: 866
    edited 2011-05-08 02:05
    @cazman128: I'm not sure if I'm remembering this correctly, but I think PropBASIC can't handle multi-statement lines (?) So
    IF X > 1.1 AND X < 1.45 THEN forward
    
    should probably be broken down to:
    IF X > 1.1 THEN
      IF X < 1.45 THEN
        forward
      ENDIF
    ENDIF
    

    HTH
  • GerryKeelyGerryKeely Posts: 12
    edited 2011-05-08 05:23
    Hi
    syntax for multi line statement is
    If X > 1.11  AND
    X <  1.45 THEN 
     FORWARD
     ENDIF
    


    regards
    Gerry
  • cazman128cazman128 Posts: 25
    edited 2011-05-12 20:04
    Thanks for the help everyone..almost there, im starting one more thread for help with a cog problem please help if you can!

    thanks everyone..

    caz
Sign In or Register to comment.