Using a DAT block to provide a sequence of commands and values
Loopyonion
Posts: 24
Hi,
Ive been having a look if this is possible, and thought i'd ask the experts out there, before i pour countless hours into why it wouldnt work. Basically, id like to have a DAT block, that i could use to feed a series of instructions and values.
Think of it like a CNC program, where I can state:-
move to position 1, wait 100ms, perform this action, wait 200ms.. and so on.
Heres my principle:-
The aim would be POSITION 2, WAIT for 100ms, then POSITION 1. When 255 is read, then thats the end of the line. Could I use something different for end of line, as the values i need to use will be between 0 and 5000 as thats the longest time in millisecs i would want to wait for. Maybe a character?
then calling:-
Is it possible, or am i barking up the totally wrong tree?
It would be nice to have a command sequence more like CNC, ie p002, w100,p001 etc..
Help and advice welcome ! thanks again.:)
Ive been having a look if this is possible, and thought i'd ask the experts out there, before i pour countless hours into why it wouldnt work. Basically, id like to have a DAT block, that i could use to feed a series of instructions and values.
Think of it like a CNC program, where I can state:-
move to position 1, wait 100ms, perform this action, wait 200ms.. and so on.
Heres my principle:-
'P = POSITION'W = WAIT G1 WORD "P",2,"W",100,"P",1,255
The aim would be POSITION 2, WAIT for 100ms, then POSITION 1. When 255 is read, then thats the end of the line. Could I use something different for end of line, as the values i need to use will be between 0 and 5000 as thats the longest time in millisecs i would want to wait for. Maybe a character?
then calling:-
PUB pattern_sequence | Step, Command, Value Repeat until Step := 255 Step := 0 Command := word[G1][Step] Step++ Value := word[G1][Step] Step++ case Command POSITION : pos(Value) ' POSITION SUBROUTINE WAIT : wait(Value) ' WAIT TIME SUBROUTINE
Is it possible, or am i barking up the totally wrong tree?
It would be nice to have a command sequence more like CNC, ie p002, w100,p001 etc..
Help and advice welcome ! thanks again.:)
Comments
Would you mind explaining the :-
Using posCmd, instead of "P" would not be an issue, and aid future debugging.
The aim is, in future, to be able to use a serial transmitted string of command sequences, from a pc to the prop, the prop to store these in data blocks by writing them into memory, then on reboot, recall and execute them. ( more on this later):)
It may have been done ( more than likely) and its a multi stage project.
This I consider to be the foundation
Note that these command sequences can be very complicated. For example, you could have a repeat command that repeats the following command (or commands) a specified number of times, possibly varying the parameter used in the next command as it repeats. You could have test commands that check for some condition and skip the next command if false. You could also have a relative jump command that would jump backwards or forwards a specified number of steps. That's enough to be able to write programs in your CNC-like control language.
If all your commands require a single parameter then you could use letters for commands followed by numbers for the parameter and finish of the list with Z 0 or something unique.
I'm not that familiar with spin but Step gets set to zero at the beginning of the loop so only the first two words will be retrieved.
Regards,
Sandy
I've attached a demo program that reads and displays a command sequence (and holds when a Wait is specified).
Ill see where I end up