pov timing question
mikea
Posts: 283
I'm attempting to build a pov clock. Right now i'm only trying to make a simple smiley face with one spinning led. I was hoping someone could take a look at my code to find a timing problem. The led will do random things for around a minute or so then work when I only try a smile and one eye, when I add the second eye it all goes random. Any suggestions would be appreciated. Thanks! (there are percent signs where they need to be in the code, they wont display correctly on this forum post)
CON _clkmode = xtal1 + pll16x 'Standard clock mode * crystal frequency = 80 MHz _xinfreq = 5_000_000 var long start_time long end_time long cycle long piece 'hall effect is high, magnet makes it low pub circle dira[0..4]~~ start_time:=end_time:=cycle:=piece:=0 repeat waitpeq(%100000000000, |< 11, 0) 'wait for high hall sensor waitpeq(%000000000000, |< 11, 0) 'wait for low hall sensor end_time:=cnt ' cycle:=end_time-start_time 'figure time for one revolution start_time:=cnt 'piece is one degree resolution of 360 degrees piece:=cycle/360 outa:= %100 'turn on red led waitcnt(piece*80+cnt) 'leave on for 80 pieces of circle outa:=%0000 'turn off led waitcnt(piece*80+cnt) 'go around circle 80 pieces outa:= %100 'turn on led waitcnt(piece*20+cnt) 'leave on 20 pieces outa:=%0000 'turn off waitcnt(piece*40+cnt) 'go around circle 40 pieces outa:=%100 'turn on led waitcnt(piece*20+cnt) 'leave on 20 pieces outa:=%0000 'turn off until beginning of loop
Comments
By "Random" do you mean blinky spots, or solid arcs/circles?
One thing? I see where you pick up end_time := cnt.
But start_time is assigned zero?
What's the cnt when that happens? And happens again the next time?
I was doing a POV with a QuickStart on the ceiling fan but never found an easy way to sync it.
(details of you Hall circuit would be sweet!)
So I thought I'd use IR Remote control to "adjust" timing.
It has possibilities, but a hard index would be the way to go.
If you get ANY recognizable pattern the speed is pretty close.
But might "roll" slowly.