simple newb question


Closed Thread
Results 1 to 14 of 14
  1. #1
    PICMAN's Avatar
    PICMAN Guest

    Question simple newb question

    ok, i designed a circut with a bs2, now im converting to a pic 16f84a,, originally i hoped to learn to use this programer i got online, with suplied ic prog, programing in hex, then i found pic basic,

    ive managed to do every thing i need to basically except designate up to 4 input lines, basically im taking a signal sent to a servo,, jumping it onto a pic 16f84a,, apon an imput going high, it will cause the pic to run a sub routine till the servo is zero'd,

    i need to know how to designate an io line to input,, and if im runining this input off of one of the servos wires, will i need to do any thing so the signal sent to activate the servo doesnt fry the chip,,
    AND if i used the signal that causes movement in the servo,, will it draw enough curent off the servo to effect its operation,

    if you havent guessed it im designing a pair of digitally activated turn signals for a remote controll car, to get away from switch activated ones that rarley work, 2 io lines for turn signals, and 2 for the brake lights, ( steering has a servo , as does the carborator) a few months ago i breadboarded this on a bs2, had it all programed,, just never actually made the conection betwen the servo and the bs2, can any of you veteran pic basic buffs tell me if my therory is sound and how to designate a pin to be input

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Smile

    Hippicman,

    Have a look here :

    http://www.rcgroups.com/forums/forumdisplay.php?f=199


    You could get all the hardware info you need.

    See i.e. Mr CAM's projects.

    I already saw what you intend to realise ... very good help !!!

    Alain

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


    Did you find this post helpful? Yes | No

    Default

    i need to know how to designate an io line to input,, and if im runining this input off of one of the servos wires, will i need to do any thing so the signal sent to activate the servo doesnt fry the chip,,
    AND if i used the signal that causes movement in the servo,, will it draw enough curent off the servo to effect its operation,
    To set the pin direction (input or output) you can use TRIS or INPUT & OUTPUT statement

    TRIS:
    =====
    TRISB=%11110000 ' Set PORTB<7:4> as input. PORTB<3:0> as output

    TRISB.0=1 ' Set PORTB.0 as input

    INPUT & OUTPUT :
    ===============
    INPUT PORTB.0 ' Set PORTB.0 as input

    OUTPUT PORTB.1 ' Set PORTB.1 as output

    IMHO, it's quicker to use TRIS in one shot and place comment on the right edge

    If you need to monitor the signal from the motor, be sure the voltage is bellow 5 volt.

    You'll need a external chip driver, MOSFETs, Transistor to drive your Motor. PIC can drive/sink a maximum of 25ma.

    Welcome to the PICmicro world. Smart move from you guy!
    Steve

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

  4. #4
    PICMAN's Avatar
    PICMAN Guest


    Did you find this post helpful? Yes | No

    Default thnx steve

    thats the exact line i needed steve thnx man, since im reverse engenering this, it helps me to have the comand, then i research it, with out having the comand theres simly too much to look threw to find the right comand, appreaciate the replies, thnx for your time

  5. #5
    PICMAN's Avatar
    PICMAN Guest


    Did you find this post helpful? Yes | No

    Default does this sound right?

    ok this code is checking how to check if servo input is high or low, and assumes ill need only one wire input ( which i know i will need 2,, but is this how i call an if then sttement off that input?)

    do

    trisb.0=1 ' sets input for servo signal
    symbol rled = PORTB.1 ' BIND OUTPUT TO RB1

    if b.0 = 1 then ' if servo input is high
    rled = 1 ' right side led on
    pause 250 ' pause 1/4 second
    rled = 0 ' right side led off
    pause 250 'pause off

    if b.0 = 0 then ' if servo signal is low
    lled = 1 'left side led on
    pause 250 'pause 1/4 sec
    lled = 0 ' left led off
    pause 250 'pauses off for 1/4 sec

    else

    rled = 0 ' right leds off
    lled = 0 ' left leds off

    endif

    loop

  6. #6
    PICMAN's Avatar
    PICMAN Guest


    Did you find this post helpful? Yes | No

    Default

    just relized the botom of your post mr, ,

    its a gas truck,, no motor, i plan to run this same deal off the throttle servo,, if its pos, ( or giving the carb gass) no brake lights, the same servo also runs a ceramic brake disc and caliper,, so if its negitive the brake is engaged,,, and jualla brake ights come on, my ocncerns for ma rating,, was drawing a splice off two of the three servo wires coming from the reciever box, i think im corect in saying a simple resistor on the input line should cause no more curent then needed to go hi or low will be taken off the servo line enabling the servo to still work with a minute amount of its current drawn off to actualize the signals,, both the reciever and all servos and ic board will be run off a nicad pack,, so i assume the physics of this will alow the signal to be read off the pic,,
    as i said i built it and tested operation with out cuting into the actual servo,, wasnt wiling to pay 50 bucks for a bs2 to prouduce it, so i waited to test till i build the prototype for this model, my dad a seasond electronics major said my therories work, so i wasnt to woried about testing it b 4 proceding, at worst ,, ill build a reciever around it and negate the one in the car :P

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


    Did you find this post helpful? Yes | No

    Default

    I change some things in your code

    Code:
    trisb.0=1 ' sets input for servo signal
    ServoInput VAR PORTB.0
    
    trisb.1 = 0 ' Set RB1 as output
    rled VAR PORTB.1 ' BIND OUTPUT TO RB1
    
    trisb.2 = 0 ' set RB2 as output
    lled VAR PORTB.2
    
    ' PS : we can also define TRIS in one shot
    ' TRISB = 1   
    ' in the above, only B0 is an input
    
    Start:
    
    rled = 0 ' right leds off
    lled = 0 ' left leds off
    
    Select Case ServoInput
         Case 1
              rled = 1 ' right side led on
              pause 250 ' pause 1/4 second 
              rled = 0 ' right side led off
              pause 250 'pause off
    
         Case 0
              lled = 1 'left side led on 
              pause 250 'pause 1/4 sec
              lled = 0 ' left led off
              pause 250 'pauses off for 1/4 sec 
    end select
    
    goto start
    Last edited by mister_e; - 4th February 2005 at 20:32.
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default

    ORRRRRRR

    Code:
    TRISB = 1   
    
    ServoInput VAR PORTB.0
    rled VAR PORTB.1 ' BIND OUTPUT TO RB1
    lled VAR PORTB.2
    
    PORTB=0 ' turn leds off
    
    Start:
    
    if ServoInput then ' same as If ServoInput=1 then
              rled = 1 ' right side led on
              pause 250 ' pause 1/4 second 
              rled = 0 ' right side led off
              pause 250 'pause off
    Else
              lled = 1 'left side led on 
              pause 250 'pause 1/4 sec
              lled = 0 ' left led off
              pause 250 'pauses off for 1/4 sec 
    endif
    goto start
    Last edited by mister_e; - 4th February 2005 at 20:28.
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default

    And now for your input stuff, you can use a simple 10K - 22K resistor in serie for sure. OR use a 7.5K in serie + 5.1K resistor to the ground as a voltage divider. It ensure to have a better "ground" or "0" reading.

    In another hands, i still don't understand why those BasicStamp are still on the market. To Expensive for what we can do with...
    Steve

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

  10. #10
    PICMAN's Avatar
    PICMAN Guest


    Did you find this post helpful? Yes | No

    Default benifit of select case vs if then

    so is there a benifit to using select case rather then if then, i mean like less words used etc. im gonna go ahead and study how you wrote it,, im guessing since you chose that way , theres a reason ,,,

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


    Did you find this post helpful? Yes | No

    Default

    I just reedit both code .. i did mistakes .. O.K now.

    Well USUALLY SELECT CASE is use when you have multiple condition. In this case only two. The IF THEN will take less code space and do the same job.
    Steve

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

  12. #12
    PICMAN's Avatar
    PICMAN Guest


    Did you find this post helpful? Yes | No

    Default ty mr

    awsome man , again thank you for your time,,

  13. #13
    PICMAN's Avatar
    PICMAN Guest


    Did you find this post helpful? Yes | No

    Default curent spike on switch on,,

    ok just thought of this,,

    the circut this is all goin on is in a remote controll truck, when i toggle the switch to the on position for the radio equipment and servos, theres a bit of a spike threw the system sending the servo arm to jerk a bit , ( if you toggle it back and forth about 5 times the arm is in full to one extreme, ie all the way right)

    now im wondering,, is it actually a spike in curent,, or just noise,,

    in either case,, the pic needs a boot time if im correct,, perhaps an immediate jolt wouldnt be a good idea,, (since the servo curent is directly to b.0,,) to fix boot time, i could just put ic circut b4 switch,, but again ,, im still wondering if the reciever sends out a spike,, or just noise causeing movement


    in electric cars,, the same occurs, and can prouduce a slight jerk outta the car,, keep in mind this is a pretty hevy curent draw motor,, but again could be noise outta the reciever,,, causeing the speed controll to ive out a short burst,

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


    Did you find this post helpful? Yes | No

    Default

    mmmm.. let's assume that the "noise" will be less than 1 seconde

    Code:
    TRISB = 1   
    
    ServoInput VAR PORTB.0
    rled VAR PORTB.1 ' BIND OUTPUT TO RB1
    lled VAR PORTB.2
    
    PORTB=0 ' turn leds off
    PAUSE 1000 'boot delay
    Start:
    
    if ServoInput then ' same as If ServoInput=1 then
              rled = 1 ' right side led on
              pause 250 ' pause 1/4 second 
              rled = 0 ' right side led off
              pause 250 'pause off
    Else
              lled = 1 'left side led on 
              pause 250 'pause 1/4 sec
              lled = 0 ' left led off
              pause 250 'pauses off for 1/4 sec 
    endif
    goto start
    And the time you do the LED blink (500ms) can be enough to avoid some glitchs from servo motor.
    Steve

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

Similar Threads

  1. Newb Question...
    By Perrin` in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 2nd January 2009, 20:49
  2. Really simple question for you experts :)
    By lew247 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 4th June 2008, 01:43
  3. SIMPLE question
    By ngeronikolos in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 5th February 2008, 18:27
  4. really simple, dumb question
    By picster in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 3rd March 2007, 22:02
  5. really simple adcin question
    By kitcat in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 21st April 2006, 09:06

Members who have read this thread : 1

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