MrDEB
Well-Known Member
Been awhile since I visited Electro tech online as I have been distracted designing and building a recumbent bike, trike. Have a trike built and making improvements as needed / desired. Well this gets to the addition of a POV led display I want to add. My orginal desine was a BATMAN symbol as the tandem recumbent I am designing anmd building is going to have a skin on frame Batmobile, 4 wheels, two seats with independent gears for both riders. Wanting to have done for the Christmas Parade here locally but time says no way Jose.
So I am going to just add led strings to the spokes and frame of the built trike.
Have started writing code as most pov displays for a bike wheel requires the bike to travel in excess of 5-8mph. Plan to stay below 5mph. Present plan is attach led strings to spokes and light up in some sort of sequence. Utilizing two magnets 180 degrees apart on the bike frame or two hall sensors and one magnet. Time the interval from trigger point A to point B (180 degrees apart) then using the interval as a variable, multiply by 2. The code I have posted is testing to sense the time between button presses (using a Tap-28 board for testing and software uart). This code seems to work but feel I am missing something but what? I found I needed a switch de-bounce as the display screen showed weird outputs.
Using the variable extracted from the time interval to cycle through the data bits. Any suggestions appreciated as this may not be the correct method to go??
So I am going to just add led strings to the spokes and frame of the built trike.
Have started writing code as most pov displays for a bike wheel requires the bike to travel in excess of 5-8mph. Plan to stay below 5mph. Present plan is attach led strings to spokes and light up in some sort of sequence. Utilizing two magnets 180 degrees apart on the bike frame or two hall sensors and one magnet. Time the interval from trigger point A to point B (180 degrees apart) then using the interval as a variable, multiply by 2. The code I have posted is testing to sense the time between button presses (using a Tap-28 board for testing and software uart). This code seems to work but feel I am missing something but what? I found I needed a switch de-bounce as the display screen showed weird outputs.
Using the variable extracted from the time interval to cycle through the data bits. Any suggestions appreciated as this may not be the correct method to go??
Code:
{
*****************************************************************************
* Name : UNTITLED.BAS *
* Author : [select VIEW...EDITOR OPTIONS] *
* Notice : Copyright (c) 2013 [select VIEW...EDITOR OPTIONS] *
* : All Rights Reserved *
* Date : 10/08/2013 *
* Version : 1.0 *
* Notes : testing of trigget timing *
* : *
*****************************************************************************
}
Device = 18F2420
Clock = 8
Include "convert.bas"
Include"suart.bas"
Include"InternalOscillator.bas"
Dim R_un As Word
Dim led1 As PORTA.5
Dim led2 As PORTB.3
Dim count As Word
Dim s1 As PORTB.5
Dim s2 As PORTB.4
dim Trigger as word
UART.SetBaudrate(sbr9600)
UART.SetMode(umTrue)
UART.SetTX(PORTB.7) ' matches the PICkit 2 UART tool input pin when connected to the ICSP connector
Output (led1)
Output(led2)
led1=1
led2 = 1
input (S1)
input (S2)
R_un = 0
While 1 = 1
if S1 = 1 and R_un <1 then ' waiting for button press
delayms(100) 'switch debounce
R_un = 0
end if
If s1 = 0 and S2 = 1 Then ' button press
delayms(100) 'switch debounce
R_un = R_un + 1 'count time between pressing of S1 and S2
Low (led1) ' led1 is on
UART.Write("run =",DecToStr(R_un), 13, 10)
end if
if S1 = 1 and S2 = 1 then ' time between pressing S1 and S2 no button press
delayms(100) 'switch debounce
R_un = R_un +1 ' continue counting tiome between press of S1 and S2
end if
if S2 = 0 then Trigger = R_un ' S2 is pressed
delayms(100) 'switch debounce
UART.Write("Trigger =",DecToStr(Trigger), 13, 10)
Toggle (led1) ' turn off led1
low (led2) ' turn on led2
delayms(500)
toggle (led2) 'led2 off
R_un = 0 ' reset timer R_un
End If
UART.Write("run =",DecToStr(R_un), 13, 10)
Wend