First timer...building a remote controlled vehicle


Closed Thread
Results 1 to 33 of 33

Hybrid View

  1. #1
    Join Date
    Jan 2009
    Posts
    20

    Default First timer...building a remote controlled vehicle

    I have a science Olympiad tournament coming this month and for my project I am going to build a remote controlled vehicle. I can probably do the motor and turning part. But I need someone to help me with the transferring of data to the the pic chip in the controller (12F or 16F prob.) to the one the car (12F or 16F).

    maybe using the technique found under the "five-button V2 transmitter and receiver (old)" heading at http://jap.hu/electronic/codec-v4.0.html

    Please, please help me on this. Thank you by the way

    okay, I will be using either a 12F683 pic chip or a 16F684. I have two zilog transreceivers and IR detectors and stuff. Here are the links for some of the things I bought:

    transceiver - https://www.mouser.com/Search/Produc...X1810MV115TH29

    Infrared Emitter/Sensor Assemblies SMD Slotted Optical Switch
    https://www.mouser.com/Search/Produc...ey512-QVE00033

    I will try to buy whatever you guys suggest as long as you have tried it before and you know that it works. Please help out.


    The major thing I would need help with would be button debouncing as it does not seem to work with if then statements for me and how to send data to the another pic (either the 12F or 16F above) using the transceiver. Maybe code examples, links, and anything that can help me out would be great.

    thank you all!

    deadline? Jan 27th !!!!
    Last edited by .n0rig.; - 15th January 2009 at 21:59.

  2. #2
    Join Date
    Apr 2005
    Location
    Virginia
    Posts
    65


    Did you find this post helpful? Yes | No

    Default

    .n0rig.,

    I can't speak too much to the IR transmitter you're looking at, but I can point you in the direction of some other options. If time and ease outweigh cost, one option is to use a pre-built transmitter/receiver pair that uses standard serial data, like:

    http://www.parallax.com/Store/Access...%2cProductName

    You need both the transmitter and receiver. The link above takes you to a deal where you save a little money by buying two of each, but also on that page, below the picture, is a link to the transmitter and receiver by themselves. Unfortunately, I haven't used these personally (yet) but they use a simple serial interface like serout. The code provided isn't in PBP, but it is a form of BASIC, so it will help get you started. If memory serves, I think you'd use serout2 on the transmitter side and serin2 on the receiver side. That's it! No figuring out how to encode or decode IR signals. Plus, you'll get much better range (~500') and not nearly as much interference and noise as you would with IR.

    If you're hooked on IR and want to keep it cheap, I'd search the forum for using a standard TV remote control with a simple IR detector. I did that many moons ago, so it ain't too hard to figure out. In that way you don't have to spend additional time building a transmitter and writing code for it.

    Now, if you're ambitious, another option is to interface with a wireless Playstation 2 controller. Again, you don't have to build a controller or write software for the remote, because it's already done. Additionally, the PS2 has analog joysticks, so you could have your car's speed and steering controlled proportionately, assuming you have the supporting motor controls. In other words, instead of pushing one button to move the car forward at one set speed, you could push up on the joystick and as the stick was moved forward, the car would increase it's speed. It's a digital output, so you don't have to go so far as to use the ADC on the PIC. Check out this post for a little more info: http://www.picbasic.co.uk/forum/showthread.php?t=10386

    This will likely take the most time to program and debug however and as you're on a tight schedule, I leave it for you to decide which, if any of these, suit your needs best. I hope this helps.

    -Tony

  3. #3
    Join Date
    Jan 2009
    Posts
    20


    Did you find this post helpful? Yes | No

    Default

    thanks tony, I figured the whole serin and serout deal but I was just wondering if I can do that on any of the pic's pins? I will look at the datasheets of the pics I am doing but can you give me a label I should for if any. I am going to assume that any pin will work, trial and error will fix this for me.

    Also, I know this is going to sound really dumb, but it is something I have been trying to fix for such a long time. I have been trying to use button debouncing with if then statements but they don't seem to work.

    Let us say this is the beginning of my code:
    Code:
    gosub rightbuttoncheck  ;high then check right side. If right not, then restart.
    
    goto start
    
    rightstart:
    gosub nap54ms
    if GPIO.3 = 0 then start
    
    gosub checkRmode
    
    rightstart2:
    nap 6               ; low power mode for 1.152 of a sec.
    if rightbutton = 0 then start
    I don't know how to do a "if tact switch (momentary) is pressed, then goto [labe]" type of deal. I tried using the "button" command but that just gave me too many errors that I just dropped it. I was thinking of putting assembly in the and using btsfc or whatever I know some assembly...just to get me around and understand what a program is doing.

    So, if I had a a chip, a wire connect to that chip's pin, that wire to a pin of a momentary tact switch, then the other end to the ground or ground pin of the pic chip. How would I do that in basic, will the above If then statements work...well...they have not worked with me even when I change it to "if rightbutton = 1 (or a 0) then [label]".

    Regards and thanks for everything!

    P.S. are there any cheaper alternatives to this...is there no example code I can follow?

  4. #4
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by .n0rig. View Post
    thanks tony, I figured the whole serin and serout deal but I was just wondering if I can do that on any of the pic's pins?
    SERIN, SEROUT, SERIN2, SEROUT2, . . . YES, HSERIN HSEROUT, NO on these you must use the hardware ports
    Quote Originally Posted by .n0rig. View Post
    Also, I know this is going to sound really dumb, but it is something I have been trying to fix for such a long time. I have been trying to use button debouncing with if then statements but they don't seem to work.

    Let us say this is the beginning of my code:
    Code:
    gosub rightbuttoncheck  ;high then check right side. If right not, then restart.
    
    goto start
    
    rightstart:
    gosub nap54ms
    if GPIO.3 = 0 then start
    
    gosub checkRmode
    
    rightstart2:
    nap 6               ; low power mode for 1.152 of a sec.
    if rightbutton = 0 then start
    I don't know how to do a "if tact switch (momentary) is pressed, then goto [labe]" type of deal. I tried using the "button" command but that just gave me too many errors that I just dropped it. I was thinking of putting assembly in the and using btsfc or whatever I know some assembly...just to get me around and understand what a program is doing.

    So, if I had a a chip, a wire connect to that chip's pin, that wire to a pin of a momentary tact switch, then the other end to the ground or ground pin of the pic chip. How would I do that in basic, will the above If then statements work...well...they have not worked with me even when I change it to "if rightbutton = 1 (or a 0) then [label]".

    Regards and thanks for everything!

    P.S. are there any cheaper alternatives to this...is there no example code I can follow?
    Just use 2 if then loops with a short delay between them.
    Code:
    LOOP:
    If portA.1 = 1 then
    pause 5
    if PortA.1 = 1 then
    { your code here}
    ELSE
    goto LOOP
    ENDIF
    ENDIF
    
    GOTO LOOP
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Joe S. View Post
    SERIN, SEROUT, SERIN2, SEROUT2, . . . YES, HSERIN HSEROUT, NO on these you must use the hardware ports
    Some thing about that sounds...funny
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Jan 2009
    Posts
    20


    Did you find this post helpful? Yes | No

    Default

    ok, I got the IF THEN statement to compile in one of my other codes. As for this remote controller car, how would I got about controlling two DC or three DC rumble motors from an xbox 360 controller? I really wanted one that you can control the speed on but dang...those cost a lot and for something like this, I don't want to blow my money on little 2 in x 2 in things that cost over $100.

    Anyways, I'm guessing PWM is not an option on these? How about pulsout? I just want to make these things make the car go forward, reverse, stop (if possible), and have a 3rd small one controll the steering of the front tires. The motors would have separate power sources from the pic chip. I believe the guidelines said to not use over 5 or so volts in total...I can bring extra batteries and I only need the car to operate for a few minutes. I am guessing a tripple A for the front motor and 2-3 double A's for the pic and two back motors. Maybe add some other components to make the whole thing work. But this is the idea for now. Oh, I have a few 16F684 chips and 16F636, 16F616 and an 18F that I never used. I usually buy 100's of 12F683 though :P.

    I like the 12F683 and the 16F684 because they both have the same modules and stuff. The datasheets are practically similar...except the 16F has 14 pins. So, this is the pic I want to use.

    sooo, what are my options?
    Last edited by .n0rig.; - 16th January 2009 at 03:33.

  7. #7
    Join Date
    Jan 2009
    Posts
    20


    Did you find this post helpful? Yes | No

    Default

    sorry double posted

  8. #8
    Join Date
    Jan 2009
    Posts
    20


    Did you find this post helpful? Yes | No

    Default

    triple...please erase these last two.
    Last edited by .n0rig.; - 16th January 2009 at 04:08.

  9. #9
    Join Date
    Apr 2005
    Location
    Virginia
    Posts
    65


    Did you find this post helpful? Yes | No

    Default

    .n0rig.,

    I'll try to get more detail to you this evening if you need it, but here's some info to get you started.

    The button command will work on any I/O so long as the pin you select is set to a digital output. As I'm a little more familar with 16 and 18 series, let's stick with the 16F684. Now, most of the pins on this chip can be used as analog or comparator inputs, so you need to turn these off. Something like this (sorry, this is quick and dirty):

    Code:
    CMCON0 = %00000111    ' Turn off comparator bits and set pins to digital I/O
    ADCON0.0 = 0               ' Disable ADC
    TRISC = %00001111       ' Make port c pins 0-3 inputs and the rest as outputs 
    b0   VAR    byte    ' Byte variable for button
    HIGH PORTC.4
    
    Start:
    
    BUTTON PORTC.0, 0, 255, 0, b0, 1, drive_forward  ' If button is pressed, goto drive_forward routine
    
    GOTO Start
    
    drive_forward:
        LOW PORTC.4
        PAUSE 500
        HIGH PORTC.4
        PAUSE PORTC.4
    goto Start
    Now, as far as hookup, you should connect a 10k resistor to 5V (whatever is powering VDD) and to pin RC0. Connect one side of the momentary switch to RC0 and the other to ground. Connect the positive side of an LED to 5V and the other to, say, a 1k resistor and the other side of the resistor to RC4. Assuming I made no mistakes, you should see the LED blink once when you press the switch.

    To control motors, it depends on what you want to do. If you're NOT trying to vary the speed and just want to turn the motor on and off (one speed), I'd look at an H-bridge IC or make one with transistors or MOSFETs. Another option is to use a DPDT and a simple SPST relay, which you'd have to interface to the PIC with transistors or an optoisolator. The DPDT will change the direction will the SPST will turn the motor on and off. If you do want to vary the speed keep in mind your controller must be able to vary the signal to the PIC as well. If you want to go this route, I'd search the forum on PWM and/or motors. The rumble packs are just simple brushed DC motors as far as I know, so if one speed is okay, you just feed them power and they go - they don't need PWM to function. You would use PWM to vary the speed, but my knowledge on this subject is limited at best.

    As far as steering, I'd use a cheap servo and the PULSOUT command. Optionally, you could use continuous servos for the wheels too and get varying speed easy with the PULSOUT command, but it won't go very fast.

  10. #10


    Did you find this post helpful? Yes | No

    Default Robotic control via TV remote control

    I just found out about this website. So, this information may be too late to use.

    On the other hand, your original post was on Jan 15, 2009.

    Microchip has an application note, AN657, that shows you how to decode TV remote control signals. The application note includes source code.

    You make a table of the decoded codes for the buttons you want to use.

    Then write simple subroutines for each task you need to do.

  11. #11
    Join Date
    Jan 2009
    Posts
    20


    Did you find this post helpful? Yes | No

    Default

    Can you please post the link ????

  12. #12
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  13. #13
    Join Date
    Jan 2009
    Posts
    20


    Did you find this post helpful? Yes | No

    Default

    Okay, deadlines are this saturday. I got the chips communicating with a wired connection. On a 16F684 I used the pin portc.1 to communicate. I got it to send a variable (but now I just changed it to two word sized variables (movement1 for forward and reverse motors, and movement2 for turns). When I did one veriable, it worked perfectly by using this:

    Code:
    TRAIN VAR BYTE
    movement1 var word
    movement2 var word
    
    PORTc.1 = 1 'turn enable pin high
    TRAIN=$55
    
    SEROUT PORTc.1,T2400,[TRAIN,TRAIN,TRAIN,TRAIN,TRAIN,9,movement1,movement2]
    
    goto get_actions
    goto start
    and this to receive:
    *movement1 and 2 have been declared in the beginning of code
    Code:
    TRAIN VAR BYTE
    
    Start:
    
    PORTc.1 = 1 'turn communication pin high
    TRAIN=$55         
    SERIN PORTC.1,T2400,[9],movement1,movement2
    gosub get_actions
    
    goto start
    
    forward:
    forwardleft:
    forwardright:
    backward:
    backwardleft:
    backwardright:
    turnleft:
    turnright:
    nomov:
    the last labels are where my actions to route power to the motors will go...that will be the simpler part I suppose.

    Also, I want to add buttons to my remote control. It will simple momentary tact buttons but I still do not understand what will need to be hooked up to make this stuff work. Basically, I will need around 6 buttons or so...maybe all in the porta pins. That will be the basic way to do it...given each direction a button (e.g. L, R, FL, FR, Rl, RR). But now I am thinking of using the two movement word variables (movement1 & movement2) to do two things at once. So, when I press R and the forward button (almost like a dpad), it will send out those two variables to the chip in the car. But Idk how to make those two variables run at the same time . Like...if I am doing left and forward, then I want left and forward to be enabled at the same time.
    *actually...wouldn't tris and port commands do this quicky?


    It's late and I am tired...

    anyways, here is what I have for the buttons as described above...will this section of code work work with momemtary tact switches like I said? Or do I have to use the button command? If I am missing or doing something wrong in any part of this...please, please help me out. Also, if you have any tuts or previous codes your wrote and don't mind PMing me...then please do.

    Code:
    get_actions:
    if leftbutton = 0 then 
    turns = 1                   ;turns = 1 means a left turn
    else
    turns = 0                   ;no turn at all
    endif
    
    if rightbutton = 0 then
    turns = 2                   ;turn = 2 means a right turn
    else
    turns = 0                   ;no turn at all
    endif
    
    if backwards = 0 then
    forwardsandback = 1
    else
    forwardsandback = 0
    endif
    
    if forward = 0 then
    forwardsandback = 2
    else
    forwardsandback = 0
    endif
    
    goto start                   ;now we have all the buttons pressed at this small
                                 ;interval of time...we need to send it.
    *the serout command is located after start

    I have been working on this for a long time and have spent so much money that I decided to buy those rentron transmitter and receiver pair. I did next day shipping on it too as I need them fast.

    If I were to use tho...will I have to encode anything or can I just connect the transmitter to the remote control pin and the receiver to the car?

    Oh, I bought these:
    1 - RXLC-315-LR High-Performance RF Receiver Module
    http://www.rentron.com/remote_control/RXLC-434LR.htm
    1 - TXLC-315-LR High-Performance RF Transmitter Module
    http://www.rentron.com/remote_control/TXLC-XXX-LR.htm


    I got the full code compiling but just a few things I am not sure about stilll...I have the chassis and also ordered some motors from...well...for now I forgot the place. But it was like 10 DC motors and stuff...


    ONE MAJOR QUESTION!!!!
    How do I make my car stop? I mean, using a DC motor...if u take the currect away from it, the car will still keep on rolling...how can I make it so that it locks up and stops? Is it possible by reading the adc or something and making it go postive, then negative then positive (pulse???) make it stop?

    Please give me something to work on that above guys.

    Regards,

    n0rig

    P.S. Pin diagram attached is not final...just something that I keep on erasing and stuff...then changing it again.

    P.S.S. Help me because this is my first time using PicBasic
    Attached Images Attached Images  
    Last edited by .n0rig.; - 3rd February 2009 at 07:29.

  14. #14
    Join Date
    Jan 2009
    Posts
    20


    Did you find this post helpful? Yes | No

    Default

    some funny thing that happened...I ordered some wireless transceiver RF chips from mouser.com (great place ) but they were so tiny and I don't have the equipment to solder to them that they are just now sitting there. Also, can these work (I got like 10 of them while I ordered my regular stuff from them...)?

    http://www.mouser.com/Search/Product...579-MCP201-E/P

  15. #15
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by .n0rig. View Post
    ONE MAJOR QUESTION!!!!
    How do I make my car stop? I mean, using a DC motor...if u take the currect away from it, the car will still keep on rolling...how can I make it so that it locks up and stops? Is it possible by reading the adc or something and making it go postive, then negative then positive (pulse???) make it stop?

    Please give me something to work on that above guys.
    To make a PM motor brake, short the power leads together, so the current the motor is generating works to stop the rotation. Obviously you would disconnect power first
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  16. #16
    Join Date
    Jan 2009
    Posts
    20


    Did you find this post helpful? Yes | No

    Default :(

    Guys, I could not get the car working . I lost...but can take it to states

    For some reason the data being sent, even when wired, would not work. I was using several if then statements but I think that some small discrepancy was what was making it not work.

    I have posted my code above and would like someone to help me out with the trisa, porta things. I believe that is where i have messed up.

    Please guys, support me on this and help me out.

    Thanks...

Similar Threads

  1. Elapsed Timer Demo
    By Darrel Taylor in forum Code Examples
    Replies: 111
    Last Post: - 29th October 2012, 17:39
  2. Pulse Capture and byte building
    By boroko in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 21st July 2009, 01:59
  3. TV remote controlled RGB LEDs
    By idtat in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 22nd February 2009, 17:15
  4. Timer interrupt frequency
    By Samoele in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 17th January 2009, 23:49
  5. Need help building a simple IR learning remote with a PIC
    By JackPollack in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 20th April 2006, 22:22

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts