We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello, i am working on a very simple logyc analyzer.
The hardware is made of an arduino which semd through serial this kind of data:
100:20:20
Where the first number is the time in microseconds when the pulse is high, the second low, and the last is the duty cycle.
Processing read everything correct from arduino
My problem is in drawing it. I tried with lines and points but i m not able to draw it correct
Answers
Please post the code you have so far. Also, for drawing this info, you would need to clarify the relationship btw duty cycle value and the pulse itself.
Kf
my arduino code as i said send this kind of data:
the duty cycle is calculated with this:
here processing:
the comunication isn't a problem, but i really don't have any idea why it doesn't work. and i m quite sure that i m doing it in a stupid and complicated way but it s the first time that i have hand on processing
https://forum.Processing.org/two/discussion/16618/processing-with-arduino-void-serialevent#Item_1
GoToLoop thank you but i don t think you have read my previously post: i don t have problem with the comunication. I get exactly the data that i want but i m not able to use them in processing
My data are two: The time in which the pulse is hight and the time in which is low. And from them i should draw just two lines proportionally to the value of the data
@aster94 -- currently nobody can copy/paste and test your code, because it is not formatted correctly. Please format it correctly as per How to Format Code.
To debug, first separate your drawing logic from your serial logic, so that you can test your draw logic with either a stored string or with randomly generated numbers.
It looks like your draw loop is unbounded in ways that cause you lots of problems.
Y_LOW
andY_HIGH
in capitals as global constants; assignxPos
in setup to make it clear that it is not a constant.This test sketch does it with a mouse click:
Another line plotting example, but using key presses as input: :)
http://studio.SketchPad.cc/sp/pad/view/ro.9cfU11egvzT6G/latest
I will try! But my first idea was to have it real time. The serialEvent(); fires every time processing receive a new data, correct?
By default, serialEvent() is triggered for every single byte received:
https://Processing.org/reference/libraries/serial/serialEvent_.html
But we can change that w/ either bufferUntil() or buffer():
https://Processing.org/reference/libraries/serial/Serial_bufferUntil_.html
https://Processing.org/reference/libraries/serial/Serial_buffer_.html
hi, i completed it, works very well, i will do a few little adjustmet but its ok it is completely different to the first code i wrote, i use more line(); than point(); because they were to slow, then i add a few texting of data
i didn't put the serial event since for you is better to create some random values if you want to play it
thanks to everyone!
the only stuff that i don't understand is why when i arrive near the edge it don't draw the line untill it