First timer...building a remote controlled vehicle


Closed Thread
Results 1 to 33 of 33

Hybrid View

  1. #1


    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.

  2. #2
    Join Date
    Jan 2009
    Posts
    20


    Did you find this post helpful? Yes | No

    Default

    Can you please post the link ????

  3. #3
    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.

  4. #4
    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.

  5. #5
    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

  6. #6
    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.

  7. #7
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    .nOrig.,

    Unfortunately, the MCP201 ICs you ordered from Mouser aren't RF tranceivers. These are
    bidirectional serial interface ICs. See section 1.0 device overview in the MCP201 data
    sheet: http://ww1.microchip.com/downloads/e...Doc/21730d.pdf

    P.S.
    Thanks for the order. I'll have a free copy of our RF code examples CD included/shipped
    with your order today.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  8. #8
    Join Date
    Jan 2009
    Posts
    20


    Did you find this post helpful? Yes | No

    Default

    Wow bruce Thanks. I did receive it today and I am planning on working on it later tonight (the cd was in there and those files look very helpful). I am going to attach what I have as of now for both my receiving and transmitting chip (both 16F684). I would like you guys to correct me on some stuff because I had it working the day prior to yesterday (but it was just the serin and serout without the "get_direction" label and the forward, backwards, left, right labels as well), but now it has stopped working.

    Here is the code for the 16F684 that will be connected to the transmitter:
    *also, how can I make a circuit with about 4 buttons using my 7mm tact switches so that I can get the values and send them out over serout?
    **what is needed...I am still unclear on this, is it a 10k resistor or something. A simple diagram would be helpful (maybe with an accompanying piece of code )
    ***keep in mind that this is my first project ever in PBP, I have pieced stuff together from other's posts and stuff I have read. I have managed to get the somewhat good amount of knowledge that I possess of assembly programming (and all the stuff that you may learn from it) to better understand my code.

    Transmitter chip code (beta - malfunctioning?):
    *I was playing with the data being sent out and making it my own numbers so it is just a loop between start and the serout command...so I can test the receiver pic...which isn't working for some reason

    Code:
    '****************************************************************
    '*  Name  : Electric car (4 motors and remote controlled) for Science Olympiad*
    '*  Author  : GiroTechs                         *
    '*  Notice  : Copyright (c) 2009 GiroTechs                      *
    '*          : All Rights Reserved                               *
    '*  Date    : 1/14/2009                                         *
    '*  Version : 1.0                                               *
    '*  Notes   : this is a single attempt to make a remote controller electric *
    '*          : vehicle with both reverse and forward plus steering *
    '*          : capabilities as well as a stop button.            *
    '* major code piece that baffled me came from:
    '*http://www.picbasic.co.uk/forum/showthread.php?p=50584#post50584
    '* THANK YOU n qwerty!
    '****************************************************************
    '
    '             power   ^   ground
    '              RA5         RA0
    '              RA4         RA1
    '              RA3         RA2
    '              RC5         RC0
    '              RC4         RC1
    '              RC3         RC2
    '
    Include "modedefs.bas"
    '
    ' ——-[ Equates ]———————————————————————————-
    '
    FLbutton var porta.0          ;left side forward
    FRbutton var porta.5         'right side forwad
    BLbutton var porta.1       ;left side backwards
    BRbutton var porta.4       ;right side backwards
    rightbutton var portc.5          ;just turn right
    leftbutton var  porta.2           ;just turn left
    
    act1 var word
    act2 var word
    
    
    ;Create a changing pulsewidth signal from 10 usec wide to 655 
    ;msec wide.
    pulsewidth   var    word
    
    ;end equates
    
    ;Main start
    start:             
    TRISA=%00000000
    TRISC=%00000010
    
    OPTION_REG.7=0 'Enable Pull-Up's on PORTB
    
    ANSEL = 0 'turns off analogue inputs
    
    OSCCON =$60 'sets internal osc to 4MHz
    
    TRAIN VAR BYTE
    movement1 VAR WORD
    movement2 var word
    
    direction var word
    turns var word
    
    PORTc.1 = 1 'turn enable pin high
    TRAIN=$55
    movement1 = 4
    movement2 = 1  
    direction = movement1
    turns = movement2
    SEROUT PORTc.1,T2400,[TRAIN,TRAIN,TRAIN,TRAIN,TRAIN,9,movement1,movement2]
    
    
    goto start
     
    
    END
    
    
    
    ;
    ;subroutines
    ;
    
    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 FLbutton = 0 then
    direction = 1
    else
    direction = 0
    endif
    
    if Frbutton = 0 then
    direction = 2
    else
    direction = 0
    endif
    
    goto start                   ;now we have all the buttons pressed at this small
                                 ;interval of time...we need to send it.
    
    ;***RAN out of space on this post, you will need to get this part of code ;from the next one below.
    ;

    My Receiving pic's code:
    *in the previous code, I set it up to send fixed data so I can see if the pins are being enabled or not. As it turns out, my code isnt working for some reason. 2 days ago I had it working but idk what could be wrong because I know that "movement1" and "movement2" are being received (wired connection). Any help by looking over my if then statements and all that would be apreciated

    Code:
    '****************************************************************
    '*  Name  : Electric car (4 motors and remote controlled) for Science Olympiad*
    '*  Author  : GiroTechs                         *
    '*  Notice  : Copyright (c) 2009 GiroTechs                      *
    '*          : All Rights Reserved                               *
    '*  Date    : 1/14/2009                                         *
    '*  Version : 1.0                                               *
    '*  Notes   : this is a single attempt to make a remote controller electric *
    '*          : vehicle with both reverse and forward plus steering *
    '*          : capabilities as well as a stop button.            *
    '* major code piece that baffled me came from:
    '*http://www.picbasic.co.uk/forum/showthread.php?p=50584#post50584
    '* THANK YOU n qwerty!
    '****************************************************************
    '
    '             power   ^   ground
    '              RA5         RA0
    '              RA4         RA1
    '              RA3         RA2
    '              RC5         RC0
    '              RC4         RC1
    '              RC3         RC2
    '
    Include "modedefs.bas"
    '
    ' ——-[ Equates ]———————————————————————————-
    '
    forwardL var porta.0          ;left side forward
    forwardR var porta.5         'right side forwad
    backwardL var porta.1       ;left side backwards
    backwardR var porta.4       ;right side backwards
    right var portc.5          ;just turn right
    left var  porta.2           ;just turn left
    rec var   portc.1           ;receiver pin
    
    action var byte
    B1 var byte
    movement1 VAR WORD
    movement2 var word
    
    direction var word
    turns var word
    
    ;Create a changing pulsewidth signal from 10 usec wide to 655 
    ;msec wide.
    pulsewidth   var    word
    
    ;end equates
    
    ;Main start
                 
    TRISA=%00000000
    TRISC=%00000010
    
    OPTION_REG.7=0 'Enable Pull-Up's on PORTB
    
    ANSEL = 0 'turns off analogue inputs
    
    OSCCON =$60 'sets internal osc to 4MHz
    
    TRAIN VAR BYTE
    
    Start:
    
    PORTc.1 = 1 'turn communication pin high
    TRAIN=$55         
    SERIN PORTC.1,T2400,[9],movement1,movement2
    movement1 = direction
    movement2 = turns
    goto checkdirection
    
    goto start
    
    forward:
    if turns = 0 then
    goto forwardgo
    if turns = 1 THEN 
    goto forwardleft
    if turns = 2 then
    goto forwardright
    endif
    endif
    endif
    forwardgo:
    high forwardl
    high forwardr
    pause 500
    low forwardl
    low forwardr
    
    goto start
    
    forwardleft:
    forwardright:
    
    backward:
    if turns = 1 then
    goto backwardleft
    if turns = 2 then
    goto backwardright
    endif
    endif
    
    high backwardl
    high backwardr
    pause 500
    low backwardl
    low backwardr
    
    goto start
    
    backwardleft: 
    backwardright:
    turnleft:
    
    high left
    low right
    pause 500
    low right
    low left
    goto start
    
    if turns = 0 then
    goto start  
    if turns = 1 THEN 
    goto checkturns
    if turns = 2 then 
    goto turnright
    endif
    endif
    endif
    
    goto turnright
    
    turnright:
    
    low left
    high right
    pause 500
    low left
    low right
    
    if turns = 0 then
    goto start  
    if turns = 1 THEN 
    goto turnleft
    if turns = 2 then 
    goto checkturns
    endif
    endif
    endif
    
    goto turnright
    
    nomov:
    
    
    goto start
    
    
    ;
    ;subroutines
    ;
    checkdirection:
    ;forward and backwards
    if direction = 0 then
    goto start  
    if direction = 1 THEN 
    goto forward
    if direction = 2 then 
    goto backward
    endif
    endif
    endif
    
    checkturns:
    ;forward and backwards
    if turns = 0 then
    goto start 
    
    start_turn: 
    if turns = 1 THEN 
    goto turnleft
    if turns = 2 then 
    goto turnright
    endif
    endif
    endif
    goto start
    
    ;left and right turns
    
    
    return
    
    
    
    
    end
    
    ;Subroutines
    nap18ms:
    
    clearwdt        ;let us make these nap intervals accurate by resetting the
    nap 0           ;the watch dog timer on the PIC itself.
    return
    
    nap54ms:
    gosub nap18ms
    gosub nap18ms
    gosub nap18ms
    return
    
    nap108ms:
    gosub nap54ms
    gosub nap54ms
    return
    
    nap216ms:
    gosub nap108ms
    gosub nap108ms
    return
         
    nap540ms:
    gosub nap108ms
    gosub nap108ms
    gosub nap108ms
    gosub nap108ms
    gosub nap108ms
    return
    
    nap1080ms:
    gosub nap540ms
    gosub nap540ms
    return
    
    nap1512ms:
    gosub nap1080ms
    gosub nap108ms
    gosub nap108ms
    return

    Thanks guys for helping me out, and bruce...for some reason you taking the care to responding to this thread and knowing that it was me that ordered the other day really shows that ye top you guys are at the top of your game around here. I am wanting to talk to you about something I want to do...it involves selling chips and stuff.

    Just get back to me at my email "GiroTechs [at] gmail".

    Thanks for your help all!

    Regards,

    n0rig

    P.S. If you can help me out with my code please, please do it quickly as I will need to have a working piece with a remote control (transmitter chip connected to tact switches to designate what the motors connected to the receiving chip will do).
    Last edited by .n0rig.; - 4th February 2009 at 21:06.

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