Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Decimal delays #4

Open
MarkAYoder opened this issue Aug 27, 2014 · 4 comments
Open

Decimal delays #4

MarkAYoder opened this issue Aug 27, 2014 · 4 comments

Comments

@MarkAYoder
Copy link

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

@deepakkarki
Copy link
Owner

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!

@MarkAYoder
Copy link
Author

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

@deepakkarki
Copy link
Owner

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.

@shubhi1407
Copy link

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

img_0170
img_0171
img_0172
img_0173

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants