I have one of these that I no longer need (no GLCD). We can do another contest similar to the last one.
Attachment 5332
Walter, do you want to administer this one as well?
Printable View
I have one of these that I no longer need (no GLCD). We can do another contest similar to the last one.
Attachment 5332
Walter, do you want to administer this one as well?
The objective of the contest is pretty simple - to pulse/blink a minimum 4 LEDs (more is better) at independent, variable rates using any PIC of your choice. The actual blink rate is not important, as long as it is visually discernible. Also, the method to adjust the blink rate is unimportant - you can use POTs on ADC channels or whatever method you want.
Sounds easy? There's a small catch though - each LED must ramp-up and ramp-down in brightness from 0 to 100% and NOT just toggle hard-on and hard-off.
RMTEO, Hats off to you this is very generous.
Now I realize this new contest hasn't been approved yet, but I have 1 question. Should the intensity change with each blink, ie each LED will need to blink 200 times to go through the full ramp up/ramp down?
This is a very good contest idea. Thank you!! (did I mention I love puzzles?)
The blink rate/frequency has to be adjustable for each of the LEDs. For every blink, each LED should ramp from 0-100-0% brightness. Perhaps this video of 2 LEDs will give you a better idea (note that the blink rate is different for each LED).
http://www.youtube.com/watch?v=aV_EhVvKEAg
Blinky ideas??
http://www.picbasic.co.uk/forum/show...47&pagenumber=
Unfortunately, none of those ideas will qualify - they are just simple ON/OFF blinkies. Take a look at the attached drawing. The horizontal axis is time and represents the blink rate. The vertical axis is the LED brightness. The post that you linked to is like the upper trace. What I am looking for (as in the video above) is shown in the lower trace.
Also, the blink rate (or period) needs to be adjustable by some method of your choice. A minimum of 4 LEDs/channels are required. The blink rate of each LED needs to be adjustable independently and should not affect any of the other channels.
Hopefully senior members (who may not wish to participate in the contest) will chime in with tips/tricks and/or code snippets to help the less experienced get started.
Seems like you are doing a fine job rmteo, and great challenge! If you still want help, let me know, I would be happy to.
Is Mibam allowed, or is that cheating? http://www.picbasic.co.uk/forum/cont...-Modulation%29 .
Thanks for your offer. I will handle it for now. You could move this to a more appropriate forum if you think it should be.
Any technique (including MIBAM) is good.
Feel free to ask questions or to have any points clarified.
Is this a first valid answer wins contest, or post and vote.
The puzzle is coming along fine, I have it on a slow simmer. :)
Right now I am trying to decide on min and max frequencies. I am thinking .5 to 1000 Hz. But clearly 1K will look just full on, so I may go with 500hZ. Anything less then .5hZ will just be painful to watch.
Also trying to work out resolution for the frequency. Seems like it should not be linear with the pot adjust.
Some pointers to take note of:
1. The variable/controllable blink rate should range from about 0.5Hz to no more than 8Hz - anything faster will appear as a flicker, which you do not want.
2. As the LED goes from full OFF to full ON and back to full OFF, its brightness has to be varied using some kind pulse modulation such as PWM or MIBAM. The frequency of this modulation has to be high enough that there is no flickering as the LEDs pulsate. Refer to the video and especially the drawing posted previously.
In essence, each of the LEDs is being driven by 2 modulated signals at the same time. A low frequency one from 0.5-8Hz which is the blink rate and a higher frequency one that controls the 0-100-0% percent brightness ramp which gives the LEDs a pulsating effect - instead of just going OFF-ON-OFF.
Hint: Think FM.
Thanks for the more refined parameters. This should help us all. It at least helps me to not have to decide on the spread. :)
The hint is very nice, thank you. I guess my solution is that, but haven't thought about FM since college. As soon as I could get away from analog I did. Guess thats why I am a machinists. LOL
I hope I have not confused you (or anyone else) with these explanations. Trying to put the concept into layman's terms is lot trickier than I thought. In technical terms the objective is:
To create 4 independently controllable, low frequency (0.5-8Hz) channels of analog signals (triangle waveform in this case) using digital modulation (such as PWM) with the LED's acting as a low-pass filter.
Now that sounds a lot easier to do, doesn't it? ;)
Well actually I thought it was fine before.
Bert, have you made progress? Looks like no one else (besides Walter and yourself) has a solution for this contest. Do you (Walter, or anyone else) feel that perhaps it is too difficult and the contest should be changed to something simpler?
PM sent :)
Four days to go - and it looks like there may be only one entry. :):):)
I just saw this contest now.
<---- darn tag under my name... :D
That is a very nice experiment board. I've been using the Lab X1 lately.
I thought the GLCD was misplaced but I found it so the development board is like in the 1st. post. It comes with a PIC18F4620 - you can use any PIC16F or PIC18F in 40, 28, 20, 18, 14 and 8 pin DIP packages. I installed a ZIF socket in the 40-pin position.
http://www.picbasic.co.uk/forum/atta...2&d=1302189493
If anyone is interested, I have a PDF of the manual (it is too large at 2.5MB to upload).
Oh! The prize gets even better. Is anyone working on this contest? I hate to see a great prize and contest not even attempted!
you have shamed me into it. LOL!
I am putting it together now, likely I will slide in just under the april 30 deadline.
Heres my code so far. It appears to work as needed, but thus far I have only tested it with a sim. I will try and put the hardware together tonight and test it in real time.
All comments welcome. I did this all software (no hardware PWM) as I thought it would be more fun.Code:' Name : RMTEO Contest 2.pbp
' Compiler : PICBASIC PRO Compiler 2.6A
' Assembler : MPASM
' Target PIC : 16F1947
' Hardware : RMTEO Contest
' Oscillator : internal
' Keywords :
' Description : PICBASIC PRO program to drive 4 LED's at independent speeds
' adjustable from 4 pot's. fade from 0-100-0% for each cycle
'
'
'
'
' Configure ports
'
'
ANSELA = %00001111 'port A 0-3 analog 4-7 digital
ANSELE = %00000000 'port E all digital
ANSELF = %00000000 'port F all digital
ANSELG = %00000000 'port G all digital
CM1CON0 = %00000000 'No comparaters
CM1CON1 = %00000000
CM2CON0 = %00000000
CM2CON1 = %00000000
' preload latches before setting direction
LATB = %00000000
LATC = %00000000
LATD = %00000000 'LED's 0 for red, 1 FOR GREEN should start red
LATF = %00000000 ' low nibble is drive enable. 1 disables
LATG = %00000000
' I/O direction
TRISA = %00001111'x,x,x,x,p3,p2,p1,p0
TRISB = %00000000'x,x,x,x,led3,led2,led1,led0
TRISC = %00000000'UNUSED
TRISD = %00000000'UNUSED
TRISE = %00000000'UNUSED
TRISF = %00000000'UNUSED
TRISG = %00000000'UNUSED
'REMOVE THIS LINE IF NOT SETTING THE CONFIGS IN CODE SPACE
@ __config _CONFIG1,_FOSC_INTOSC & _WDTE_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _CPD_OFF & _BOREN_OFF & _CLKOUTEN_OFF & _IESO_OFF & _FCMEN_OFF
@ __config _CONFIG2,_WRT_OFF & _VCAPEN_OFF & _PLLEN_ON & _STVREN_OFF & _LVP_OFF ;_BORV_25
'------------------Internal osc setup
OSCCON = %11110000 'clock is 8 meg. turn on PLL for 32 meg clock
DEFINE OSC 32
DEFINE NO_CLRWDT 1
'Variables
'Port assignments
'------------------port B
'---------------------words
freqs1 var word
freqs2 var word
freqs3 var word
freqs4 var word
freq1 var word
freq2 var word
freq3 var word
freq4 var word
'---------------------Bytes
TICKS VAR BYTE
display VAR BYTE
duty1 VAR BYTE
duty2 VAR BYTE
duty3 VAR BYTE
duty4 VAR BYTE
myflags var byte
'---------------------Bits
led1 var display.0
led2 var display.1
led3 var display.2
led4 var display.3
df1 var myflags.0
df2 var myflags.1
df3 var myflags.2
df4 var myflags.3
'---------------------INIT VARIABLE VALUE
GOTO START
MYINIT:
BSR = 0
TICKS = 0
freqs1 = 128
freqs2 = 256
freqs3 = 512
freqs4 = 1023
duty1 = 0
duty2 = 0
duty3 = 0
duty4 = 0
display = 0
MYFLAGS = 0
'-------------------A/D setup
adcon0 = %00000001
adcon1 = %11100000
define ADC_BITS 10
'-------------------10uS interrupt setup
DEFINE INTHAND _TimeBase
PIR1.1 = 0
PIE1.1 = 1 ; Enable Timer2 interrupts
INTCON.6 = 1 ; enable PEIE
INTCON.7 = 1 ; enable GIE
T2CON = %00000100 ; Setup Timer2 AND SET PRESCALE TO 1:1. @32Mhz THE Interrupt
PR2 = 39' FOR TMR2 WILL BE 10uSec
RETURN
'---------------------start of program
START:
GOSUB MYINIT
MAIN:
adcin 0,freqs1
'-------------------------led1 math
if ticks>duty1 then
led1 = 0
else
led1 = 1
endif
if freq1 > freqs1 then
if df1 then
duty1=duty1+1
else
duty1=duty1-1
endif
if duty1=100 then df1=0
if duty1=0 then df1 = 1
freq1 = 1
endif
adcin 1,freqs2
'------------------------led2 math
if ticks>duty2 then
led2 = 0
else
led2 = 1
endif
if freq2 > freqs2 then
if df2 then
duty2=duty2+1
else
duty2=duty2-1
endif
if duty2=100 then df2=0
if duty2=0 then df2 = 1
freq2 = 1
endif
adcin 2,freqs3
'------------------------led3 math
if ticks>duty3 then
led3 = 0
else
led3 = 1
endif
if freq3 > freqs3 then
if df3 then
duty3=duty3+1
else
duty3=duty3-1
endif
if duty3=100 then df3=0
if duty3=0 then df3 = 1
freq3 = 1
endif
adcin 3,freqs4
'---------------------------led4 math
if ticks>duty4 then
led4 = 0
else
led4 = 1
endif
if freq4 > freqs4 then
if df4 then
duty4=duty4+1
else
duty4=duty4-1
endif
if duty4=100 then df4=0
if duty4=0 then df4 = 1
freq4 = 1
endif
GOTO MAIN
'-----------------------ISR
TimeBase:
BSR = 0
portb = display ' update led's
freq1 = freq1 +1
freq2 = freq2 +1
freq3 = freq3 +1
freq4 = freq4 +1
if ticks >99 then
ticks = 0
else
ticks = ticks+1
endif
pir1.1 = 0 ' clear interrupt
@ RETFIE
Thanks for the contest RMTEO! Sorry I seem to be the only one entering.
Yes, it will be interesting to see how it works!
Well I am done at work today, so home I go and hopefully get this put together and running. :)
Then to figure out about posting video - always something new and fun
OK, I have my working do-hicky video'ed. Anybody have any suggestions how to get it from my iphone4 to here?
I know how to upload it to facebook, but what good is that?
If you can get it to youtube, that is probably the easiest way. Then add the link to your post, like this {video}your youtube link{/video} but with the other kind of brackets.
Oh dear. Guess it's time I learn to post on you tube now. I hope I figure it out before the deadline. Ok, I'll be back in a little bit.
Don't worry about the deadline.
well you know, i have created the youtube account. sent the video to youtube via my phone. Now I just need to find the video on youtube. seems this part is the hardest.
I did it (I think)
http://www.youtube.com/watch?v=5rkDxDKvgNs
whats better? getting my entry in or posting my first video? Hmmmm
Looking at the video, it sure looks like you did it. Can you confirm that the drive to the LEDs looks similar like this (only two channels shown) - you don't have to make a video of the scope trace.
http://www.youtube.com/watch?v=YtH0BTmyaFM