Shop OBEX P1 Docs P2 Docs Learn Events
Need help getting PSC working — Parallax Forums

Need help getting PSC working

bulkheadbulkhead Posts: 405
edited 2006-03-19 20:49 in General Discussion
I ran the test program for a single pin connection, but it seems to get stuck when it tries to get a reply from the PSC. In addition, I can't get the servos to respond to any commands, they only jitter when I turn the power on. Here is my wiring diagram, and it says to connect like this:
One pin:   o---JavPin--------PscPin---o (this pin has 220E pullup resistor with LED)




(sorry, if you can't see, it says "pin 10" on the very left, "PSC" on the very right)

Did I connect it correctly? I used a 330 because I dont have another 220 right now. The 220 in the diagram is just a safety resistor I have on all my pins, and it shouldn't affect it, correct? I have the PSC's logic running off the javelin's regulated 5V, the servos running off a 6.0V battery pack (connected through the power terminals). Any help would be appreciated, thanks.

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-03-18 05:15
    According to figure 6 in psc manual (last page)
    the psc board has two leds:
    a red led to indicate board is powered
    a green led with 220 ohm that connects between Serial In and +5V
    So·you must not connect a led+resistor yourself to the psc datapin.

    As I don't have a psc board, can you confirm those leds are there?

    regards peter
  • bulkheadbulkhead Posts: 405
    edited 2006-03-18 05:35
    Peter, I tried connecting the two directly, but it still didn't work. I checked and there is a tiny green and red led on the board. I then tried changing pins, and now it works! In theory it should have worked on any of the javelin's 16 I/O pins, right? I guess this pin is dead.

    I don't know what I'm doing wrong that's causing all these pins to die out. I think this is my 3rd one in 3 or 4 months. I have 220 ohm resistors on each pin, shouldn't that protect them? The strange thing is that these don't go out if I accidently incorrectly wire something. They just seem to go out randomly. Some while being used, others during durations where they weren't used. So, if I don't use a pin, does it matter what I do with it?

    Also, is there an issue with changing your wiring and THEN programming the javelin? There is a fraction of the second from the time I hit the power switch to the time I click "program," and during this short time period, the javelin is already running the old program with the new wiring configuration. Likewise, if I download the new program and THEN change the wiring, there will be a short duration after programming when the javelin begins executing the new code on the old circuit. Is there a way round this? How is it supposed to be done?

    Post Edited (bulkhead) : 3/18/2006 5:38:27 AM GMT
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-03-18 05:51
    In the psc class I stated
    ·* One pin:·· o---JavPin
    PscPin---o (this pin has 220E pullup resistor with LED)
    ·*··········· In this case receive uart equals transmit uart
    ·*··········· static Uart pscIO = new Uart(Uart.dirReceive,CPU.pin0,Uart.dontInvert,Uart.speed2400,Uart.stop1);
    ·*··········· static psc myPsc = new psc(pscIO,pscIO,3); //single PSC board with 3 servos
    ·*
    so the pins should connect directly (as you have now).

    Glad to hear it does work. Too bad about your dead pin.
    I think the weak pullups are enabled on the SX48 of the javelin,
    but it is good practice to make unused pins a low or high output
    instead of leaving them float.

    But even then, unused pins don't get dead by themselves, even if floating.
    You say you have 3 or 4 dead pins, all on the same javelin?

    Changing the circuitry with an old program running, or downloading
    a new program with an old circuitry, COULD cause damage, but your
    220 ohm resistors should protect the pins. A way around is to first download
    a 'clear javelin' program that leaves all pins inputs, then change the circuitry
    and then reprogram with the new program.

    regards peter
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-03-18 06:18
    A note on the psc led pullup

    JavPin o---<220E>---<RES>---+----<220E>--<LED>---o +5V
    ············································ |
    ············································ +--o PscPin

    RES is an optional additional resistor.
    Treshold level is 2.5V
    If JavPin is pulled low, the PscPin level must be < 2.5V
    So RES has a upper limit value.
    Normal leds have a 2V drop when lit (I am not sure about smd leds, could be < 2V)
    so (220+res)/(220+res+220)*(5V-2V) < 2.5V
    You can work out the maximum·value for res

    With a single line, the Uart must change from transmit to receive.
    If the PscPin changes direction faster than JavPin, then
    JavPin could still be a high output, while PscPin becomes a low output.
    This gives for a short time, a current of 5V/(220E+res)
    (this also applies to the Javelin TX pin in the two pins setup)
    The javelin should be able to handle this.
    For extra protection you can connect res between JavPin and PscPin.

    regards peter
  • bulkheadbulkhead Posts: 405
    edited 2006-03-18 07:17
    Ok, thanks for the quick responses. I'll use that clear program before I modify my circuit. Yeah, the dead pins are on the same javelin, my first microcontroller. Perhaps it is because it was my first one, and it took all the abuse I gave it (from my lack of experience). My other javelin works fine for all pins, probably because I have learned to be more careful with handling it. Anyways, I should clear up a bunch of extra pins to use with the addition of my servo controller to handle the servos, thanks!
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-03-18 12:22
    There is a good chance, your dead pins still operate as inputs (and thus usable for uart receive)
    because mostly the output driver circuitry is destroyed due to too high·current draw.
    Worthwile checking I think.

    regards peter
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-03-18 12:45
    Working out the mentioned formula:

    res < (Vled/(2.5-Vled))*220 ohm
    For Vled=2V -> res < 880 ohm
    For Vled=1.5V -> res < 330 ohm
    For Vled=1V -> res < 147 ohm

    A too high res value results in PscPin level never to go below treshold level.
    I think res=150 ohm is a good extra safety precaution (I expect Vled ~ 1.5V)
    Pin peak current is then limited to 5V/(220+150) = 13.5 mA

    regards peter
    ·
  • bulkheadbulkhead Posts: 405
    edited 2006-03-19 03:52
    Ok, thanks Peter, I'll try that. I got the software working with the PSC, as well as from my javelin. The software's values for position range from 500 to 2500, the ones in the PSC class range from 250 to 1250. Is the conversion simply x2 or is there an offset or some other way of calculating it?
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-03-19 04:39
    The psc class also uses angles.
    It states

    · //convert position to angle
    · //default position range 1250-250=1000 equals 180 degrees, so angle resolution is 0.18 degrees
    · //the conversion uses 0.1 degree resolution
    · // A = (p-pmin)/(pmax-pmin)*1800
    Default pmax=1250, pmin=250, center=750 -> 90 degrees (value 900)
    pmax=2500, pmin=500, center=1500 -> 90 degrees

    · //convert angle to position
    · //default position range 1250-250=1000 equals 180 degrees, so angle resolution is 0.18 degrees
    · //the conversion uses 0.1 degree resolution
    · // P = (A/1800)*(pmax-pmin) + pmin
    Default pmax=1250, pmin=250 90 degrees -> center=750
    pmax=2500, pmin=500 90 degrees -> center=1500

    The angle/position conversion works ok for your pmin and pmax values.
    Just use your pmin and pmax values in the initChannel() method.
    That should work.
    If you use angles in your main code, then your main code is independant
    from pmin and pmax values (and thus independant from any particular servo).

    regards peter
    ·
  • bulkheadbulkhead Posts: 405
    edited 2006-03-19 04:46
    I do plan to use degree measures in my program, which is a good idea. However, I need to find the pmax and pmin values that give me 180 degrees of servo travel. If I could just use the PSC's software and USB connection, it is much easier than programming the javelin and using the debug window to enter values until I obtain my pmax and pmin for my servo.

    Do the values pmin and pmax represent the pulse duration in milliseconds? How about the PSC software's numbers?
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-03-19 04:58
    The values 250 to 1250 are the values for the psc board.
    value 750 represents 50% pwm dutycycle.
    Now I think of it, you must use pmin=250 and pmax=1250
    in the initChannel method.
    The numbers you mentioned are from the pc software fro the psc.

    You can use these numbers in your javelin code,
    just use

    ··setPosition(channel,ramp,position/2)
    and
    · position = 2*getPosition(channel)
    and
    · position = 2*position(channel,angle)
    and
    · angle =·angle(channel,position/2)


    where position is 500 to 2500

    regards peter



    Post Edited (Peter Verkaik) : 3/19/2006 5:04:57 AM GMT
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-03-19 05:19
    Or to make it simpler,
    use pcvalue_pmax/2 and pcvalue_pmin/2 and pcvalue_home/2 in
    initChannel() method.
    So if your pc values are 523, 2460, 1480
    use initChannel(channel,523/2,2460/2,1480/2,ramp)

    regards peter
  • bulkheadbulkhead Posts: 405
    edited 2006-03-19 07:40
    Ok, thanks Peter. I tried the conversion, and it works great.

    One other issue that I have come up upon while working on this is what is the proper way to turn on everything? Originally when I had servos controlled directly by PWM, I had 2 power switches, 1 for my javelin and 1 for the servos. I would turn on my javelin first, wait for it to start up, then turn on all my servos. This eliminated the potentionally disastrous random jerks of the servos that usually occur if I turn everything on at once.

    However, I can't do that with the PSC. If I don't have the PSC's power switch turned on when I turn on my javelin, it won't be initialized properly and won't work. The PSC's logic is powered by the javelin's regulated 5V, so when I switch on my javelin the red LED turns on on my PSC. If I turn on my PSC after starting my javelin, the green LED flashes indicating the data transfer, but the servos won't go to their correct positions.

    My guess is that the PSC's power switch is not JUST linked to the servo ports, but also to the logic somehow. The only way I can get it working now is if I turn on the javelin and the PSC at the same moment (the switch to my javelin is the "master switch", so to achieve this I just leave my PSC's switch on and hit this "master switch"). When I do this the servos do jerk for a second, but then they work fine afterward. How can I eliminate this jerk, and yet still have the PSC properly "initialized"?

    Another bit of info, if I turn on my PSC and javelin at the same time and get them working, and then I turn off my PSC. When I turn the PSC back on it no longer works. Again, this seems to point to the PSC's switch being linked to it's logic.
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-03-19 08:01
    According to the schematic (last page of manual)
    the psc logic is powered by 5V. The servo power,
    which MUST be a seperate power supply, is switched
    on/off by the psc switch.
    So the correct sequence must be:
    psc switch to OFF
    power the javelin (and thus psc logic)
    psc switch to ON

    You can call initChannel with a ramp parameter representing
    a longer time to position the initial servo positions.
    You can add a delay before initializing the servos
    to allow you time to switch ON the servos.

    regards peter
    ·
  • bulkheadbulkhead Posts: 405
    edited 2006-03-19 08:19
    Ok, I followed that sequence, and for some reason, it works fine now. In fact, I can turn the PSC's power switch on and off, and it still works afterward. I can eliminate the jerk now by turning on my PSC after turning on my javelin. I looked at the code for the PSC, and it makes sense that this works since there is no need to send an initialize byte or something to the PSC. Also, when powered on, the PSC likes to put all the servos to the mid point (750 or 1500) and THEN move toward the specified home position at the specified ramp rate. I can avoid this by turning on the PSC's switch a few seconds after the PSC is first initialized in my program.

    Thanks again for all the help.
  • bulkheadbulkhead Posts: 405
    edited 2006-03-19 20:19
    Ok, today when I tried it, it no longer works, it has the same problem as it had before. I have to turn everything on at the same time for it to work, otherwise, the PSC wont respond to anything. I hooked it up directly through the USB port, and it works fine. When I connect it to my javelin, the green LED on the PSC flashes indicating that the javelin is sending the commands, but I guess the PSC isn't following them. If I do turn everything on at the same time and get it working, and then I reset the power to the servos, they will no longer respond.

    I looked at the schematic for the PSC (serial version), and if it's anything like the USB version, it doesn't look like the PSC's power switch is connected in any way to it's logic. Shouldn't it generate the PWM signal on the pins even thought the servo's power switch is off, as long as the logic is recieving power? The only thing I can see that may cause this problem is if the baudrates for the javelin and the PSC are not equal and they are off-sync, but the manual says you can send it a byte to "elevate" it to 38k4, so that would imply the default baudrate on the PSC is 2400. If that's the case, then they should not be off-sync since nowhere in the PSC class does it change the baudrate to 38k4.

    Again, the javelin's I/O line is connected directly through a 220 ohm resistor to the PSC. The PSC's logic is powered by the javelin's 5V. The servos are powered by the main 6.0V battery (which powers everything). I have already checked the voltage, and it stays constant at around 5.9 V and the javelin doesn't reset, so power usuage shouldn't be an issue.
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-03-19 20:49
    I think you need to have a startup delay before initializing the servos.

    import stamp.core.*;

    static void initServos() { //move servos to home positions
    · myPsc.initChannel(0,500/2,2500/2,1500/2,0);
    · myPsc.initChannel(1,500/2,2500/2,1500/2,0);
    · myPsc.initChannel(2,500/2,2500/2,1500/2,0);
    · //etc.
    }

    static void main() {
    · System.out.println("psc program version x\n");
    · System.out.println("turn on psc and hit enter when servos ready\n"); //let psc move servos to midpoint
    · int c = Terminal.getChar(); //wait for keypress
    · initServos(); //move servos to home positions
    · //insert·your maincode here
    }

    This allows you to figure out if a startup delay makes it possible
    to power up the servos later than the javelin.

    regards peter
Sign In or Register to comment.