![]() |
|
#1
|
|||
|
|||
|
Does anyone know what I am doing wrong?
I am using a V2 ISOPOD with v0.5 code. I have a servo tester program that works Ok using mainly all Forth code. But when I converted the juicy part to ISOMAX, it doesn't work as expected. I have attached the program to this message also. There are two buttons if you don't push either button then the servos stop, if you push either button the servos run forward or backwards respectively. This word RUN works OK as expected : RUN PA5 ON? PA6 ON? AND IF LSTP RSTP THEN PA5 OFF? DUP REDLED SET IF LFWD RBCK THEN PA6 OFF? DUP YELLED SET IF LBCK RFWD THEN ; EEWORD But in the program the ISOMAX version of RUN only executes the state that causes the servos to stop. It never executes the states that have the servos run forward or backwards. MACHINE RUN EEWORD ON-MACHINE RUN APPEND-STATE STP EEWORD ( SERVOS STOP APPEND-STATE FWD EEWORD ( SERVOS FORWARD APPEND-STATE BCK EEWORD ( SERVOS REVERSE IN-STATE STP CONDITION PA5 ON? PA6 ON? AND CAUSES LSTP RSTP THEN-STATE STP TO-HAPPEN IN-EE IN-STATE FWD CONDITION PA5 OFF? DUP CAUSES REDLED SET LFWD RBCK THEN-STATE FWD TO-HAPPEN IN-EE IN-STATE BCK CONDITION PA6 OFF? DUP CAUSES YELLED SET LBCK RFWD THEN-STATE BCK TO-HAPPEN IN-EE Thanks Earl |
|
#2
|
|||
|
|||
|
Look like you missed an IF in both states: FWD & BCK after SET based on the working RUN word.
Last edited by nmitech : 04-20-03 at 03:35 PM. |
|
#3
|
|||
|
|||
|
Well that confuses me even more.
In one of the example programs they have a IN-STATE QTBACK CONDITION 16FT PB7 OFF? OR CAUSES RSTP REDLED ON YELLED OFF GRNLED OFF THEN-STATE QTENDIT TO-HAPPEN IN-EE Which doesn't use IF THEN per se, it uses CAUSES and THEN instead. I tried this: IN-STATE BCK OK CONDITION PA6 OFF? DUP CAUSES YELLED SET IF LBCK RFWD THEN THEN-STATE BCK TO-HAPPEN IN-EE OK OK and this: IN-STATE BCK OK CONDITION PA6 OFF? CAUSES PA6 OFF? DUP YELLED SET IF LBCK RFWD THEN THEN-STATE BCK TO-HAPPEN IN-EE OK OK But then only the first STP State ever seems to be executed, it skips or ignores the FWD and BCK states. Thanks Earl |
|
#4
|
|||
|
|||
|
try this,
IN-STATE FWD
CONDITION PA5 OFF? CAUSES REDLED SET LFWD RBCK THEN-STATE FWD TO-HAPPEN IN-EE IN-STATE BCK CONDITION PA6 OFF? CAUSES YELLED SET LBCK RFWD THEN-STATE BCK TO-HAPPEN IN-EE Sorry, the extra DUP on the previous states FWD & BCK are put an extra data on stack each time it executes. I was read THEN instead of THEN-STATE. My bad! Also I am not sure if you want to run the same state each time it exits its state. Such as , IN-STATE FWD ... .. THEN-STATE FWD and, IN-STATE BCK ... ... THEN-STATE BCK .... I think it is OK, but i just want to verify. Last edited by nmitech : 04-20-03 at 05:49 PM. |
|
#5
|
|||
|
|||
|
Well that was a very good point, that had me all excited
so i changed this portion of code like so: MACHINE RUN EEWORD ON-MACHINE RUN APPEND-STATE STP EEWORD ( SERVOS STOP APPEND-STATE FWD EEWORD ( SERVOS FORWARD APPEND-STATE BCK EEWORD ( SERVOS REVERSE IN-STATE STP CONDITION PA5 ON? PA6 ON? AND CAUSES LSTP RSTP THEN-STATE FWD TO-HAPPEN IN-EE IN-STATE FWD CONDITION PA5 OFF? CAUSES REDLED SET LFWD RBCK THEN-STATE BCK TO-HAPPEN IN-EE IN-STATE BCK CONDITION PA6 OFF? CAUSES YELLED SET LBCK RFWD THEN-STATE STP TO-HAPPEN IN-EE HEX : STARTUP HALFSPEEDCPU RUN SET-STATE INIT ( C350=50000 EVERY C350 CYCLES SCHEDULE-RUNS RUN ; EEWORD I thought that the SET-STATE command being missing earlier was the problem, but now all I get is a MSG#37 in STARTUP when i try and run the program. It looks like it doesn't like the RUN SET-STATE command. I guess I'll have to ponder this for a while. I'm stuck. Thank you very much for being there at this time on the weekend, i really appreciate it. |
|
#6
|
|||
|
|||
|
Just add this,
HEX : HALFSPEEDCPU F413 FA1 ! 82 F00 ! ; EEWORD : STARTUP HALFSPEEDCPU RUN SET-STATE INIT ( C350=50000 EVERY C350 CYCLES SCHEDULE-RUNS RUN ; EEWORD |
|
#7
|
|||
|
|||
|
Thanks for the info, I had that already in the program.
I observed that the attachment was empty for some unknown reason so I just plugged it in here. I guess the attachment didn't make it though. I think it is that the RUN STATE isn't working, but since the PWM channels are initialized at 1.5ms center the servos both stop as expected, as they both have a ever so slight buzz to them at center. If I delete all the RUN STATE code and use the FORTH RUN word instead it works OK. From the Forth WORD I determined that I had three states to setup, both pushbuttons OFF, one or the other pushbutton ON, I simply ignore the fourth state of both buttons pushed. ( ISOPOD v2 REV .5 ( PA5 PUSHBUTTON ( PA6 PUSHBUTTON ( PA7 PUSHBUTTON ( PB0 LED ( PB1 LED ( PB2 LINE SENSOR ( PB3 LINE SENSOR ( PB4 LINE SENSOR ( PWMA0 SERVO PULSE OUTPUT ( PWMA1 SERVO PULSE OUTPUT HEX 0 RAM ! : HALFSPEEDCPU F413 FA1 ! 82 F00 ! ; EEWORD ( DIV BY 2 HALFSPEEDCPU 4E2 CONSTANT LOSTOP EEWORD 9C4 CONSTANT HISTOP EEWORD HISTOP LOSTOP + 2/ CONSTANT MIDWAY EEWORD : PWMLOAD E00 C@ DROP C3 E00 ! ; EEWORD : INIT HALFSPEEDCPU 0 FC3 ! ( ENABLE PB0 - 7 8000 E03 ! 61A8 E05 ! 0 E0D ! 0 E0E ! 000E E0F ! ( CENTER ALIGN FOR DIV BY 2 MIDWAY E06 ! MIDWAY E07 ! PWMLOAD ; EEWORD : LFWD HISTOP E06 ! PWMLOAD ; EEWORD : LBCK LOSTOP E06 ! PWMLOAD ; EEWORD : LSTP MIDWAY E06 ! PWMLOAD ; EEWORD : RFWD HISTOP 20 - E07 ! PWMLOAD ; EEWORD : RBCK LOSTOP E07 ! PWMLOAD ; EEWORD : RSTP MIDWAY E07 ! PWMLOAD ; EEWORD ( THIS CODE FOR RUN WORKS AS EXPECTED ( : RUN ( PA5 ON? PA6 ON? AND IF LSTP RSTP THEN ( PA5 OFF? DUP REDLED SET IF LFWD RBCK THEN ( PA6 OFF? DUP YELLED SET IF LBCK RFWD THEN ( ; EEWORD MACHINE RUN EEWORD ON-MACHINE RUN APPEND-STATE STP EEWORD ( SERVOS STOP APPEND-STATE FWD EEWORD ( SERVOS FORWARD APPEND-STATE BCK EEWORD ( SERVOS REVERSE IN-STATE STP CONDITION PA5 ON? PA6 ON? AND CAUSES LSTP RSTP THEN-STATE FWD TO-HAPPEN IN-EE IN-STATE FWD CONDITION PA5 OFF? CAUSES REDLED SET LFWD RBCK THEN-STATE BCK TO-HAPPEN IN-EE IN-STATE BCK CONDITION PA6 OFF? CAUSES YELLED SET LBCK RFWD THEN-STATE STP TO-HAPPEN IN-EE HEX : STARTUP HALFSPEEDCPU RUN SET-STATE ( I GET A MSG#37 ERROR W/ THIS LINE INIT ( C350=50000 EVERY C350 CYCLES SCHEDULE-RUNS RUN ; EEWORD SAVE-RAM HEX 7C00 AUTOSTART STARTUP Thank you very much again, Earl |
|
#8
|
|||
|
|||
|
You need to install the first state of the machine, STP SET-STATE instead of RUN SET-STATE
|
|
#9
|
|||
|
|||
|
That was it! It works now.
Of course it then showed me my logic error in the way it was running, but it only took a minute to correct the code, so it is working great now. Thank you very very much, I really appreciate it. Earl Here is the corrected code: ( ISOPOD v2 REV .5 ( PA5 PUSHBUTTON ( PA6 PUSHBUTTON ( PA7 PUSHBUTTON ( PB0 LED ( PB1 LED ( PB2 LINE SENSOR ( PB3 LINE SENSOR ( PB4 LINE SENSOR ( PWMA0 SERVO PULSE OUTPUT ( PWMA1 SERVO PULSE OUTPUT HEX 0 RAM ! : HALFSPEEDCPU F413 FA1 ! 82 F00 ! ; EEWORD ( DIV BY 2 HALFSPEEDCPU 4E2 CONSTANT LOSTOP EEWORD 9C4 CONSTANT HISTOP EEWORD HISTOP LOSTOP + 2/ CONSTANT MIDWAY EEWORD : PWMLOAD E00 C@ DROP C3 E00 ! ; EEWORD : INIT HALFSPEEDCPU 0 FC3 ! ( ENABLE PB0 - 7 8000 E03 ! 61A8 E05 ! 0 E0D ! 0 E0E ! 000E E0F ! ( CENTER ALIGN FOR DIV BY 2 MIDWAY E06 ! MIDWAY E07 ! PWMLOAD ; EEWORD : LFWD HISTOP E06 ! PWMLOAD ; EEWORD : LBCK LOSTOP E06 ! PWMLOAD ; EEWORD : LSTP MIDWAY E06 ! PWMLOAD ; EEWORD : RFWD HISTOP 20 - E07 ! PWMLOAD ; EEWORD : RBCK LOSTOP E07 ! PWMLOAD ; EEWORD : RSTP MIDWAY E07 ! PWMLOAD ; EEWORD MACHINE RUN EEWORD ON-MACHINE RUN APPEND-STATE DOIT EEWORD IN-STATE DOIT CONDITION PA5 ON? PA6 ON? AND CAUSES LSTP RSTP THEN-STATE DOIT TO-HAPPEN IN-EE IN-STATE DOIT CONDITION PA5 OFF? CAUSES REDLED SET LFWD RBCK THEN-STATE DOIT TO-HAPPEN IN-EE IN-STATE DOIT CONDITION PA6 OFF? CAUSES YELLED SET LBCK RFWD THEN-STATE DOIT TO-HAPPEN IN-EE DOIT SET-STATE HEX : STARTUP HALFSPEEDCPU INIT ( C350=50000 EVERY C350 CYCLES SCHEDULE-RUNS RUN ; EEWORD SAVE-RAM HEX 7C00 AUTOSTART STARTUP |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|