Shop OBEX P1 Docs P2 Docs Learn Events
Stingray programming troubles — Parallax Forums

Stingray programming troubles

2pietjuh22pietjuh2 Posts: 5
edited 2011-05-12 00:05 in Propeller 1
Hey everyone,

I'm quite new to programming, and this parallax unit. We are working with a lot of people from school on about 12 stingray robots.

We made a program to control te DC motors to drive the stingray, which works.

We can read our line sensors, they work fine too.

But, if we make a program reading our line sensors and controlling the DC motors with our own build program it is doing completely random things we dont want.

Does anyone know what we are doing wrong?


Thanks for the help!

2pietjuh2

UPDATE: removed code from this post, and added it in an archieve as desired :)
linefollower - Archive [Date 2011.05.11 Time 20.19].zip

Comments

  • 2pietjuh22pietjuh2 Posts: 5
    edited 2011-05-09 12:35
    does anyone know where the problem could be?
  • Roy ElthamRoy Eltham Posts: 3,000
    edited 2011-05-09 13:45
    That repeat is not in a good place, and the function geval is never called.

    This code doesn't even look like it would compile correctly. You use PST but it's not in the OBJ section.
  • MicrocontrolledMicrocontrolled Posts: 2,461
    edited 2011-05-09 14:00
    What is the local "line" variable used for in the first PUB routine of the main program?

    The reason it doesn't work is because you don't ever call the getval routine from the Start routine. The program stops instantly unless you type "getval" at the bottom of the start routine I don't exactly understand the repeat loop either.
  • StefanL38StefanL38 Posts: 2,292
    edited 2011-05-09 14:30
    Hi 2pietjuh2,

    and welcome to the propeller-forum

    You should attach your complete code to a posting.

    This is easy to do with the archive function of the propeller-tool

    In the propeller-tool activate that tab that contains your main program

    From the main-menu choose File - Archive - Project ...
    This will create a ZIP-archiv that contains all files needed to compile your code.

    Use the Go advanced button bottom right of the website to change to the advanced posting website.
    Click on Manage Attachments and upload the ZIP-archiv.

    Then we can analyse the whole thing.

    best regards

    Stefan
  • 2pietjuh22pietjuh2 Posts: 5
    edited 2011-05-11 11:29
    Hey,

    Thanks for your reactions!

    I attatched an achive with the full code. Hope someone can help me :)

    Thanks ,
    2pietjuh2
  • StefanL38StefanL38 Posts: 2,292
    edited 2011-05-11 13:24
    Hi,

    I tok a quick look into the code.

    I'm not familiar with the pwm_32-object.

    So I can do only a guessing. maybe switching on/off the motors just with 50% is too raw and maybe the repeat-loop is running too fast.
    But that's just a guessing.

    So what changes if you insert a waitcnt-command of 1 second or 0,1seconds?

    How is the line-follower-sensor connected to the propeller?

    best regards

    Stefan
  • 2pietjuh22pietjuh2 Posts: 5
    edited 2011-05-11 13:34
    Thanks,

    I will try that waitcnt-command for 0.1 second, if i try more i think I'll lose my line...

    The line-follower-sensor was originally not for the stingray. But we switched 2 cables on each sensor and connected it to pin 0,1,2,3. This was on advice of our teachers. When using the parallax serial communicator and right code it responded as expected. but when we change the code a little bit, (in this case to eg. PWM.motor(1,0,50)) it wont work anymore...

    hope I made my problem clear.

    Thanks for any help!

    2pietjuh2
  • John AbshierJohn Abshier Posts: 1,116
    edited 2011-05-11 15:49
    Your problem is not clear. You say the line sensor is connected to pins 1,2,3 and 4, but the code in linefollower.spin only reads pins 0 and 1. I recommend the following. Put the Stingray on something so that the wheels almost touch the ground. In each of the if statements put in a write statement to identify what the line sensor sees. You can then see if the line sensor sees what you think it sees and compare motor movement to the debug write statements.

    John Abshier

    PS. If I understand the code correctly, the PWM frequency for the motors is 60 Hz. Where did that come from? It looks low.
  • 2pietjuh22pietjuh2 Posts: 5
    edited 2011-05-12 00:05
    Hello John,

    I changed the pins, made a mistake in prev post.

    About the write statement, we did that. And that works. But it stops working when we change the write statement into something else.

    So we can log in the terminal the output of the sensors (eg 1111 or 1010). But to start with, we used only sensor 0 and 1.

    thanks,

    2pietjuh2
Sign In or Register to comment.