pruspeak icon indicating copy to clipboard operation
pruspeak copied to clipboard

Decimal delays

Open MarkAYoder opened this issue 11 years ago • 4 comments

I'd like a delay of less than 1ms, so I tried:

SCRIPT SET DIO[0], 1 WAIT 0.1 SET DIO[0], 0 WAIT 0.1 GOTO 0 ENDSCRIPT RUN

I got the following:

Initializing PRU Speak Illegal character '.' Traceback (most recent call last): File "./my_example_copy.py", line 87, in ret = pru_speak.execute_instruction(EX6) File "/root/pruspeak/src/userspace_lib/pru_speak/pruspeak.py", line 92, in execute_instruction byte_code = parser.parse(inst) File "/usr/local/lib/python2.7/dist-packages/ply/yacc.py", line 265, in parse return self.parseopt_notrack(input,lexer,debug,tracking,tokenfunc) File "/usr/local/lib/python2.7/dist-packages/ply/yacc.py", line 921, in parseopt_notrack lookahead = get_token() # Get the next token File "/usr/local/lib/python2.7/dist-packages/ply/lex.py", line 387, in token raise LexError("Scanning error. Illegal character '%s'" % (lexdata[lexpos]), lexdata[lexpos:]) ply.lex.LexError: Scanning error. Illegal character '.' PRU Speak object deleted

BOTSPEAK allows decimal delays, does PRUSPEAK?

--Mark

MarkAYoder avatar Aug 27 '14 20:08 MarkAYoder

First of all sorry for the shoddy error handling, I'm working on cleaner error messages.

The PRU Speak interpreter executes bytecode not the actual instructions. The python frontend in the userspace compiles the BotSpeak instruction and then gives the pru the byte code to execute. This is to make things faster and memory efficient. But the drawback is that I can't handle floats. So this week I'll be adding a WAITus instruction for a micro second wait. I hope that'll help :) P.S. I'm also planning for real float support once I move to the JIT architecture for PRU Speak!

deepakkarki avatar Aug 28 '14 00:08 deepakkarki

SInce each assembly instruction takes 5ns, why not have a WAITns?

MarkAYoder avatar Aug 28 '14 12:08 MarkAYoder

It's because it's hard to guarantee accuracy in terms of ns. A couple of inst here and there, you are already ~50-100 ns off.

deepakkarki avatar Aug 28 '14 14:08 deepakkarki

WAIT instructions can now take uS delays. Added float tokenizing to bs_lex. Sending pull request.

img_0170 img_0171 img_0172 img_0173

shubhi1407 avatar Mar 30 '15 16:03 shubhi1407