Shop OBEX P1 Docs P2 Docs Learn Events
Can you explain this one? — Parallax Forums

Can you explain this one?

James ReueJames Reue Posts: 18
edited 2008-11-04 15:46 in General Discussion
I programmed my Javelin Boe-Bot with the following code from the yahoo javelin group and it worked fine...well it use to...

Well, the code and documentation in the Roboticsv2_2.pdf is way out of whack, but I can deal with that...kudos whoever prepared the java version of the docs....

An example is the 255 value in the update() method signature.
From JBotServo1.java to JBotServo4.java, this value changes from a 2000 to a 255 with no explanation of why...
When I got to this program, I ran it, and like I said, the robot performed correctly.
Then I changed the value from 255 to 2000, to attempt to see what the difference was.
One wheel moved backwards while the other wheel moved forwards. This happened every second, with a slight pause in between; so there was no continuous rotation. It was as if the program was in some loop.
I thought i was extremely odd, so I changed the values back to 255.
Reprogrammed, and still the same thing.
I reprogrammed, same thing.
I reset...same thing.
The only thing that seemed to solve the issue was for me to unplug the board from power, shut down the IDE, plugged it back in and pressed reset. It then acted normal....
I programmed another piece of code and it worked fine.
I then thought I would give the piece of code I had before another shot, but again, the same thing happen.

What in the world is going on?

import stamp.core.*;

/**
* Drives both servo at high speed
*
* @version 1.0 5/7/02
* @author Parallax, Inc.
*/

public class JBotServo4 {
static PWM pwmR = new PWM(CPU.pin12); // create right servo
static PWM pwmL = new PWM(CPU.pin13); // create left servo

public static void main() {
pwmR.update ( 110, 255 ) ;
pwmL.update ( 240, 255 ) ;
pwmR.start () ;
pwmL.start () ;

CPU.delay(10000); // run for one second

pwmR.stop () ;
pwmL.stop () ;
}
}
«1

Comments

  • James ReueJames Reue Posts: 18
    edited 2007-09-11 05:25
    I just ran the BasicWheelServoTest1 and the exact same thing is happening. It jumps forward 1/8" every second.... It seems that anything I do with 2 servos is doing this. I can run other examples that only deal with 1 servo and it works fine...


    confused.gif
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2007-09-11 05:27
    The pwm parameters are 8bit values, so using 2000 decimal = 0x7D0 hexadecimal
    of which only 0xD0 is used (= 208 decimal)

    regards peter
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2007-09-11 05:29
    This could be a power issue, as it only happens when you control 2 servos.
    Do you use a seperate power supply for the servos?

    regards peter
  • James ReueJames Reue Posts: 18
    edited 2007-09-11 05:32
    I'm only using the supplied 4AA power pack. I have 1 wire connected from Vm to Vin(1st hole only)
  • James ReueJames Reue Posts: 18
    edited 2007-09-11 05:35
    1) How would i have an extra power supply?
    2) So is 208 the max number that can be supplied to that constructor?
  • James ReueJames Reue Posts: 18
    edited 2007-09-11 05:47
    Ok I commented out the calls to move 1 wheel and it worked. I put the calls back in, now I get this.....

    [noparse][[/noparse] Error IDE-0056] Possible Javelin on COM3 did not respond
    [noparse][[/noparse] Error IDE-0054] Unable to find a Javeling on any port.

    Seriously...what am I missing?
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2007-09-11 05:48
    The pwm update takes 2 parameters, time high and time low, both
    are 8 bit values (0-255) expressing the time in 8.68uSec units.

    Does your board not have servo connectors?

    regards peter
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2007-09-11 05:49
    Have you replaced the batteries with fresh ones?

    regards peter
  • James ReueJames Reue Posts: 18
    edited 2007-09-11 05:55
    These are brand new alkaline batteries that I opened about 4 hours ago. Can I use DC power instead?

    I have a Javelin Stamp Demo Board Rev B. It has 1 X5 jack at the top where the 2 servos are plugged into 12 and 13

    I have 1 wire running from Vm to the first hole in Vin.
  • James ReueJames Reue Posts: 18
    edited 2007-09-11 06:08
    Ok, now this is really blowing my mind.

    Why would this repeat over and over and over and over......???

    My output is
    here
    here
    here
    here
    ...

    and the wheel moves in one direction only...over and over....

    Why does this think it is in a loop? If I take out the 2nd move(-100) and delay, it works once, like advertised...

    What the hell?



    public class BasicWheelServoTest1 {
    public static void main ()
    {
    System.out.println("here");
    BasicWheelServo leftWheel = new BasicWheelServo (CPU.pin12 , 110, 175, 240, 2000) ;
    //BasicWheelServo rightWheel = new BasicWheelServo(CPU.pin13, 240, 175, 110, 2000);

    leftWheel.move ( 100 ) ;
    //rightWheel.move ( 100 ) ;

    CPU.delay(10000); // run for four seconds

    leftWheel.move ( -100 ) ;
    //rightWheel.move ( -100 ) ;

    CPU.delay(10000); // run for four seconds

    leftWheel.stop () ;
    //rightWheel.stop () ;
    }
    }
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2007-09-11 06:09
    The wiring appears ok.
    I checked JBotServo2 to JBotServo4 programs, the value 2000 is probably
    a typo and should read 200. (only values 0-255 are valid, anything above
    gets remapped into that range by using value %= 256).

    regards peter
  • James ReueJames Reue Posts: 18
    edited 2007-09-11 06:18
    I trimmed this does and noticed that if the 100 is -100, like in the docs, the entire main is run again....


    public class BasicWheelServoTest1 {
    public static void main ()
    {
    System.out.println("here");

    BasicWheelServo leftWheel = new BasicWheelServo (CPU.pin12 , 110, 175, 240, 200);

    // if this is a -100, like in the docs, all this will repeat over and over
    leftWheel.move(100);

    CPU.delay(10000);
    leftWheel.stop() ;
    }
    }
  • James ReueJames Reue Posts: 18
    edited 2007-09-11 12:07
    I'm really pulling at straws here....

    Could my version of the IDE or JBot or required lib/stamp/util/os be wrong or mismatched?
    I just now placed the required lib/stamp/util/os' package in my Javelin Stamp IDE folder. I see it overwrites Task and TaskManager.

    I have yet to do any testing though.

    Is there any up to date documentation anywhere? I'm finding my most important bits of information sprinkled all over the place, from forum postings to docs that have not been updated for well over 2 years..... I mean i had a hell of a time just getting power to the servos; i only found that I had to connect Vm to Vin by stumbling across a tiny note about it in the documentation. It seems that this would be way more visible and apparent.
  • Jon KeinathJon Keinath Posts: 146
    edited 2007-09-11 14:25
    Have you tried a fresh set of batteries, or a different supply for the servos? The above output of here,here,here makes it sound as if the Javelin is resetting due to brown out. Please try a fresh set of batteries, or a DC supply and let us know the results.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    -Jon
    www.jonkeinath.com
  • James ReueJames Reue Posts: 18
    edited 2007-09-11 15:12
    I will first try the new batteries and then the dc power and let you guys know.

    In the Robotics 2.2 pdf on page 59, we identify your board carrier.

    None of the versions listed match what I have.
    I have Javelin Demo Board Revision B, and I am just guessing as to which board it corrisponds to in this document.

    Mine resembles Board of Education Rev B mostly, except I only have X5, not both X4 and X5, and my X3 has a Vm pin.

    The reason I have not tried to plug in AC power is because the document states :
    "The Board of Education Rev B does not have a jumper setting for power. Only use the 6V battery pack as a power supply for the Board of Education Boe-Bot projects".

    Seems a little contradicting....I don't want to mess up my board...
  • James ReueJames Reue Posts: 18
    edited 2007-09-11 15:35
    Peter,
    In the examples link there is a file ServoExample.java. Notice the low parameter for each PWM of 2304.
    static PWM ServoL = new PWM(CPU.pin12,173,2304);
    static PWM ServoR = new PWM(CPU.pin13,173,2304);

    You stated yesterday:
    "The pwm update takes 2 parameters, time high and time low, both
    are 8 bit values (0-255) expressing the time in 8.68uSec units."

    So why is this value here 2304 and in the documentation examples 2000, when you said that the 2000 was probably a type and should be 200. Anything above 256 will be set to 256...

    Why would 2 completely different sources have values like this?
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2007-09-11 15:57
    James,
    My mistake. The values can be larger than 255.
    The 2304 equals 2304*8.68uSec = 19.99872 mSec = 20 mSec
    and the 173 equals 173*8.68uSec = 1.50164 msec.
    Remember servos require pulses of 1-2 msec every 20 msec.
    So the high time parameter for 1 mSec = 115*8.68uSec
    the high time parameter for 2 mSec = 230*8.68uSec
    So the high time parameter must be 115 to 230, with 173 being the stop value (1.5mSec pulse).

    regards peter
  • James ReueJames Reue Posts: 18
    edited 2007-09-11 16:50
    Now thats the type of answer/documentation I am looking for! smile.gif

    Thanks so much.

    Now, about my previous power question... Is it safe for me to use AC power with this board and the servos??
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2007-09-11 17:08
    You can use an ac/dc power source but it must be·6 VDC output.
    Since you connect Vin to Vm you cannot supply more than 6VDC
    to Vin, because the servos can only handle 6V.
    The javelin, which is powered with Vin to its pin24, can accept up to 24VDC.
    Before you connect a regulated 6VDC adapter, measure the output
    to be certain it is 6VDC. Some adapters (especially unregulated ones) may output
    a higher output voltage that only decreases·with heavy loads.
    I suggest a regulated 6VDC/1A adapter. That should give you enough power.

    regards peter
    ·
  • James ReueJames Reue Posts: 18
    edited 2007-09-11 19:00
    I will pick up one of these today to test with. But honestly, doesn't this seem overkill? I mean, what point would there be in programming a robot by using ac power source and then having it not work correctly when i want to have it run around my floor on batteries?

    Something seems fundamentally wrong with this entire situation right?
    With all the people that are using this board and stamp and the boe-bot kit, am i really the only person seeing this?

    A quick recap of my current setup: Hopefully someone can say "Oh you cant do 'that'!" or "Oh you have that piece, that wont work..."

    Javelin Demo Board Rev B
    I have a mini-usb -> serial connector plugged into it
    I have a usb cable plugged from computer to mini-usb jack on board
    Board is powered by 4 Eveready 1.5v Alkaline batteries
    I have 1 wire plugged from Vim to the 1st out of 3 Vn holes
    One servo is plugged into X5 12
    One servo is plugged into X5 13
    Using the JBot.zip files from the yahoo javelin user group
    Its unzipped in the parallax home/projects directory


    The following code, when programmed with the Javelin IDE causes the bot to barely nudge forward, over and over and over; "never" leaving the main().


    import stamp.core.*;

    public class TestServos
    {
    static PWM pwmR = new PWM(CPU.pin12);
    static PWM pwmL = new PWM(CPU.pin13);

    public static void main()
    {
    pwmR.update ( 110, 255 ) ;
    pwmL.update ( 240, 255 ) ;

    pwmR.start () ;
    pwmL.start () ;

    CPU.delay(10000);

    pwmR.stop () ;
    pwmL.stop () ;
    }
    }
  • aprunickiaprunicki Posts: 44
    edited 2007-09-11 19:25
    It looks like the problem is you are trying to run the servos at full power immediately.
    When connected to batteries, there is only enough power to do this a handful of times.
    This is written in the documentation for both the Javelin and Basic stamps regarding servos.
    You need to step the power up to 100% (and back down again when stopping). Try modifying your
    code to run the servos at say 10% of the max. As a bonus, you'll extend the life of both
    your batteries and your servos.

    The JBot example on the yahoo group includes a RampingJBot class. This steps it at 33%, 66%,
    and finally 100%. I found I had better luck increasing the number of steps myself.

    - Andrew

    Post Edited (aprunicki) : 9/11/2007 9:35:30 PM GMT
  • aprunickiaprunicki Posts: 44
    edited 2007-09-11 19:27
    Also, you should change your low values back to what you had before as Peter mentioned in an earlier post.

    - Andrew
  • James ReueJames Reue Posts: 18
    edited 2007-09-11 19:35
    Awesome reply. This sounds like a good idea. Can't wait to try later.
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2007-09-11 20:25
    James,
    Andrew is right about the batteries. And don't forget the javelin itself draws 60-65 mA.
    So when using 2000mAh batteries, these will last 33 hours max, most probably less
    when also powering servos. Originally the BOE-BOT shipped with a BS2 which
    only draws 8mA or so.

    regards peter
  • James ReueJames Reue Posts: 18
    edited 2007-09-11 21:06
    Thanks so much guys. I really hope this works.
  • HeroHero Posts: 24
    edited 2008-10-25 08:40
    hi I just got the javelin micro controller.

    I`m receiving a Error IDE 0054. I am using a usb link. This happens when I try to test the connection.

    message>>

    Found javelin on com 8, testing power.

    resetting javelin.

    The error then appears. IDE 0054 (Unable to find javelin port)
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2008-10-25 10:32
    See this thread:
    http://forums.parallax.com/showthread.php?p=656527

    However, if you are using a javelin demoboard with a usb to serial cable,
    from javelin IDE menu: Project->Global options, tab debugger.
    Click ... button.
    Add port 8 to known port list, if not already added.
    Click ok to accept.
    Then try Project->Identify again.

    regards peter

    Post Edited (Peter Verkaik) : 10/25/2008 10:38:57 AM GMT
  • HeroHero Posts: 24
    edited 2008-10-25 11:41
    I have done so.

    I now receive a

    Error IDE-0022 (Error reading from serial port) (Timeout)

    I will try the thread link.

    Thanks
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2008-10-26 01:29
    Hero,
    If you have a usb to serial cable obtained from parallax (has a FTDI chipset)
    go into the usb driver properties and set latency to minimum (1 msec).
    Usb to serial cables with other chipsets may not allow you to alter
    the latency setting and in that case I recommend to get the parallax cable.

    regards peter
    ··
Sign In or Register to comment.