Reverse commands

My problem is regarding the following link:
https://www.robotshop.com/letsmakerobots/node/33757

For movement, FRITSL use the following code:

dreverse:
low s.8
high s.9
return

dforward:
high s.8
high s.9
return

totalhalt:
low s.9
return

My results are:
dreverse = I can not make the bot take reverse more faster
dforward = Works fine 100%
totalhalt = Works fine 100% (To me... here the bot have to stop, wait a few seconds and then take reverse)

I have been reading several topics from some users.

JAX uses this code (link file: https://www.robotshop.com/letsmakerobots/node/34631):

lt_rev:
pwmout pwmdiv4, lt_PWM, period, lt_duty
low L1: L2 high
return

rt_rev:
pwmout pwmdiv4, rt_PWM, period, rt_duty
low R1: R2 high
return

About H-Bridge theory, have read this link: http://www.mcmanis.com/chuck/robotics/tutorial/h-bridge/index.html

screen2.jpg



About Differential drive, Have read this link http://picaxe.hobbizine.com/diffdrive.html

screen1.jpg




But … What Can I use to make reverse more faster  or what’s the difference between this:

lt_rev:
pwmout pwmdiv4, lt_PWM, period, lt_duty
low L1: L2 high
return

And this

dreverse:
low s.8
high s.9
return

 

Thks Guys!!!

 

I’m not sure that I
I’m not sure that I understand your question.

Do you want to know how to change your speed in reverse?

You can use PWM on reverse exactly as you do on forward. The PWM value is always positive. The other pins set the direction.

If I’ve misinterpreted the question, I’m sorry.

I read the question the same way, and,

just flipping bits high and low will always give you full speed as long as the Enable pins are tied high. If you are working with the Start Here Robot (it seems you are), the Enable pins are tied HIGH on the board (you don’t have a choice). 

Your robot will not move any faster in reverse than it does now. I would think, if you are using the robot kit, the motors should move about the same speed forward or reverse. There may be a slight difference in velocity, but, nothing too worrisome.

Hi Birdmun

I attached these links to see what do I mean!

Forward

https://mega.co.nz/#!vg1mTaib!kg-Xtr3Zy-06py01BgGc4E1Nl3KGe5YzFf2wT32yfgU

Reverse

https://mega.co.nz/#!zkcCxRBB!bh1kFFf5c9HDMQ_G7RXOmr-NRQ2uSKW-at3rJx5tl7s

Totalhalt

https://mega.co.nz/#!DtkgkSQZ!q79B2Y4GIjSUrz4AIKrhKNy4ziilefcPDJKTTxnB3gk 

My conclusion:

Forward = So fast
Reverse = Slow compared to forward
Totalhalt… To me is like a forward but 50% slower

Therefore, if exists any method to do reverse more fast, I can replace Totalhalt with Reverse… Just if I can make Reverse faster. But I think will not happen… Am I right, Birdmun?

 

     

 


I have watched your videos, and,

You have some coding issues. Your wheels should move non stop in either direction not move, stop, move, stop. Totalhalt should not move at all.

Share your code, please.

Birdmun!! Here got the Code

’ Drive and stop
servo s.2, 150
symbol trig = b.0        ; Define output pin for Trigger pulse (M2, X2 parts). Change to port.pin you end up using. Note pin b.0 = s.3
symbol echo = b.5       ; Define input pin for Echo pulse (M2, X2 parts). Also note that on the IRS pin b.5 = s.5 as used with the SRF005 header/ULTRA command.
symbol range = w1 ; 16 bit word variable for range
main:
pulsout trig,2 ; produce 20uS trigger pulse (must be minimum of 10uS)
pulsin echo,1,range ; measures the range in 10uS steps
pause 20 ; recharge period after ranging completes
let range = range * 5 / 58
if range>20 then 'My Own Test
    sound S.12, (50, 20) 'One kind of sound, if something is far.
    gosub dforward
elseif  range>=10 AND  range<=20 then
    sound S.12, (112, 10)
    gosub dreverse
elseif range<10 then
    sound S.12, (80, 20) 'Another kind of sound, if something is close.
    gosub totalhalt
 
endif
debug
gosub dforward
goto main

dreverse:
    low s.8
    high s.9
    return

dforward:
    high s.8
    high s.9
    return

totalhalt:
    low s.8
    low s.9
    return

The code

’ Drive and stop
servo s.2, 150
symbol trig = b.0        ; Define output pin for Trigger pulse (M2, X2 parts). Change to port.pin you end up using. Note pin b.0 = s.3
symbol echo = b.5       ; Define input pin for Echo pulse (M2, X2 parts). Also note that on the IRS pin b.5 = s.5 as used with the SRF005 header/ULTRA command.
symbol range = w1 ; 16 bit word variable for range
main:
pulsout trig,2 ; produce 20uS trigger pulse (must be minimum of 10uS)
pulsin echo,1,range ; measures the range in 10uS steps
pause 20 ; recharge period after ranging completes
let range = range * 5 / 58
if range>20 then 'My Own Test
    sound S.12, (50, 20) 'One kind of sound, if something is far.
    gosub dforward
elseif  range>=10 AND  range<=20 then
    sound S.12, (112, 10)
    gosub dreverse
elseif range<10 then
    sound S.12, (80, 20) 'Another kind of sound, if something is close.
    gosub totalhalt
 
endif
debug
gosub dforward
goto main

dreverse:
    low s.8
    high s.9
    return

dforward:
    high s.8
    high s.9
    return

totalhalt:
    low s.8
    low s.9
    return

One problem you have is

after debug you have gosub dforward and then goto main. Your robot will ALWAYS execute the forward command. If you are reversing or stopping, you do not want to go forward.

Why do you not use the port labels for your pins? Your chip has 4 ports A, B, C, and D. Each port has 8 pins 0-7. I may be wrong, but, it would seem to me that it would be easier to understand your code, if you called S.2 as B.2 and S.8/S.9 as C.0 and C.1 and S.12 as C.4. I am only beliving it is easier to read because the A-D ports are how I have seen them labeled. I have not before seen the S.x declaration.

perfect

Problem fixed = 2nd. gosub forward (eliminated).

About ports A,B,C,D… I will try to understand what that’s mean!! Thks Birdmun, I’ll pay more attention to code