Pages: [1] 2   Go Down
Author Topic: Small problem with laser-based persistance-of-vision system  (Read 1363 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 340
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The project is just a laser rapidly switching on and off pointed at a spinning mirror. I'm using the Digital > BlinkWithoutDelay example sketch and have the delay set to zero. The problem is the dashes created by the spinning motor are still not short enough. I can either fix this by getting a lower rpm motor or getting the laser to blink faster. Am I already at the limit of the 16MHz clock speed by setting the delay to 0 in the example sketch?
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 604
Posts: 33448
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Am I already at the limit of the 16MHz clock speed by setting the delay to 0 in the example sketch?
No, you are using millisecond delay as your delay unit. You can get faster than this.
If I were doing this I would use timer 2 to set a PWM frequency, this is steady and can go much faster than the 500 HZ a millisecond toggle will give you.
Logged

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 340
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm now using PWM like you suggested. analogWrite(laserPin, 10); for example makes a nice, short dash but I need the short dashes much closer together and I need to be able to control which dashes are there and not there to make a user defined pattern. Am I correct to say that that is not possible with PWM?
« Last Edit: May 18, 2012, 05:57:37 pm by David82 » Logged

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12579
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What sort of blink timing are you trying to generate i.e. how fast do you need the on/off transitions, and how accurately do you need them timed?
Logged

I only provide help via the forum - please do not contact me for private consultancy.

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 340
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The device (laser pointed at a spinning mirror) will be about 3-4 ft above a 4ft long flat surface and need to project about 90 dots along, and confined within, that 4ft surface. Each dot must be able to be turned on or off individually. I also need to be able to set the individual spacing of each dot relative to the dot beside it. Some dot pairs will be spread out further apart than others.

PWM is close to being fast enough but I can't control the amount of time on AND the amount off time off like I need. Is the arduino just not good enough to do this?
« Last Edit: May 18, 2012, 08:04:39 pm by David82 » Logged

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12579
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have no idea. Can you explain all that again please, but this time in terms of the timing requirements? I really don't care how far away the bits are.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 340
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

analogWrite(laserPin, 10); for example makes a nice, short dash depending on the rpm of the motor.

the value can be 0-255. If "10" is used, it is on for 10 clicks and then off for 245 clicks. I need it to be on 5 clicks, and off 5 clicks, then repeat. Do you see what I mean?
« Last Edit: May 18, 2012, 09:00:43 pm by David82 » Logged

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 340
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Am I not clear? Is this a really difficult problem to solve?
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 291
Posts: 25899
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
analogWrite(laserPin, 10); for example makes a nice, short dash depending on the rpm of the motor.
You know the PWM frequency and the duty cycle, so the pulse length should be a simple calculation.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 604
Posts: 33448
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It is a matter of synchronising the PWM output to the motor rotation.
There are many ways of doing this.
One is with a sensor for each rotation, an other is using a phase locked loop to synchronise the motor speed to the PWM frequency.

You can change the PWM frequency to be much faster than the default.
Logged

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 340
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You guys are misunderstanding the current problem a little. I'm not worried about alignment yet. Let me rephrase it this way; I need to figure out what code would give me the absolute shortest, most frequent pulses on an output pin. Imagine a square wave on an oscilloscope. I need to compress that wave as far as the arduino can handle. I need it to blink/pulse as fast as it possibly can.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 291
Posts: 25899
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I need to figure out what code would give me the absolute shortest, most frequent pulses on an output pin.
Direct port manipulation should get you up to a few mega Hertz.
Occasional glitch for timer overflow interrupts, though.
« Last Edit: May 19, 2012, 03:03:30 pm by AWOL » Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 340
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That's cool.. I have no idea what the code is for that though.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 291
Posts: 25899
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Some good search terms though
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 340
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I found this http://www.arduino.cc/en/Reference/PortManipulation but the example isn't as helpful as I need it to be.
« Last Edit: May 19, 2012, 03:14:41 pm by David82 » Logged

Pages: [1] 2   Go Up
Jump to: