First timer...building a remote controlled vehicle


Closed Thread
Results 1 to 33 of 33

Hybrid View

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

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

  3. #3
    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 04:33.

  4. #4
    Join Date
    Jan 2009
    Posts
    20


    Did you find this post helpful? Yes | No

    Default

    sorry double posted

  5. #5
    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 05:08.

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

  7. #7
    Join Date
    Jan 2009
    Posts
    20


    Did you find this post helpful? Yes | No

    Default

    Yea sounds like a good idea, I figured out how to do if then commands and I think I just figured out why my buttons were not working. I didn't signify a b0 register as a byte. Anyways, what I will need most help in will be the serout and serin to connect to the chip on the car to make the car move forward, back, etc.

    And can I use rumble motors from an xbox 360 controller for my main forward and reverse motions? can these be controlled like a servo or not? see, there is a requirement that we have to make the vehicle stop when at a certain time. The faster it stops the better.

    thanks for all your help guys!

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


    Did you find this post helpful? Yes | No

    Default

    .n0rig.,

    Code:
    Anyways, what I will need most help in will be the serout and serin to connect to the chip on the car to make the car move forward, back, etc.
    By chip, do you mean the PIC or are you interfacing the PIC to some chip on the car? You only need serin and serout if you're interfacing to a computer or another IC. Or do you mean to talk from one PIC (on the remote) to the PIC on the car?

    I doubt you can control the motors like a servo. Rumble packs are typically DC brushed motors with a counterweight on the end that act like pager motors or the vibration ringer in a cellphone. They'll be full on or off like a standard DC motor. You'd have to use PWM with some type of interface circuitry or buy a motor controller that can interface with the PIC.

    If you'd like to dive further into motor control, a quick Google search turned this up:

    http://www.newark.com/pdfs/techartic...ksBrochure.pdf

    http://ww1.microchip.com/downloads/e...tes/00893a.pdf

    http://ww1.microchip.com/downloads/e...tes/00905a.pdf

    http://www.seattlerobotics.org/encod...implemotor.htm

    I haven't looked at this in detail, but you might get away building this and using pulsout:

    http://www.aaroncake.net/CIRCUITS/motorcon.asp

    However, I think this would do everything you want and pretty cheaply:

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

  9. #9
    Join Date
    Jan 2009
    Posts
    20


    Did you find this post helpful? Yes | No

    Default

    elec_mech, you are really helpful and thank you for finding those links for me.In regards to some of your questions, yes, I will be using serout to "wireless" interface like this:

    me -> push buttons on remote -> remote has 16F684 in it -> which is connected to an RF transceiver (or transmitter "tx") -> sends the info about me pushing the button(s) -> transceiver (or receiver "rx") in car receives info -> transceiver forwards received info. to another 16F684 chip in the car that is connected to either 3 or 4 rumble motors (dc) without the weights on the spindles -> this controls forward and reverse motions. With some gears and just 3 motors (two on back and one of front between two front tires with spindle facing upward) I can make a steering system.

    That right there sums up my plan for this. I don't need anything fancy for controlling the car, nothing that exceeds 30M probably (RF quality).

    I am still lost on what actual supplies I can use that are not too expensive. If you have done something like this before I would greatly appreciate either a sample code, parts list, or guides for me. I really appreciate all of your help...this is going to be a really important event for me if I finish this as it will be one of the biggest completed codes I could possibly make. With the knowledge that I attain from this, I can put it to use in the future. Anyways, thanks...just keep all this information rolling guys.

    Regards,

    n0rig

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


    Did you find this post helpful? Yes | No

    Default

    .n0rig.,

    Ahh, okay. It's been years since I worked on an IR project, so I did a quick search on the forum under 'infrared' and found some postings you might want to check out:

    http://www.picbasic.co.uk/forum/show...light=infrared

    http://www.picbasic.co.uk/forum/show...light=infrared

    Now, by all accounts, everyone said Bruce was the man on IR and to check out the solutions on his website. These are both inexpensive and relatively easy to implement.

    http://www.rentron.com/Infrared_Communication.htm

    http://www.rentron.com/remote.htm

    http://rentron.com/PicBasic/IR_Chips.htm

    If you'd consider using a universal TV remote programmed with Sony signals, as a backup plan - I'm not encouraging you to abandon your plans for making your own remote - then: http://www.rentron.com/remote_control/IR-D15A.htm

    Hope this helps and good luck!

Similar Threads

  1. Elapsed Timer Demo
    By Darrel Taylor in forum Code Examples
    Replies: 111
    Last Post: - 29th October 2012, 18:39
  2. Pulse Capture and byte building
    By boroko in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 21st July 2009, 02:59
  3. TV remote controlled RGB LEDs
    By idtat in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 22nd February 2009, 18:15
  4. Timer interrupt frequency
    By Samoele in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 18th January 2009, 00: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, 23: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