Hi Guys,
I've had a project running for some time now (http://www.picbasic.co.uk/forum/showthread.php?t=18456) which uses DT's Multi_SPWM routine to fade up the LEDS over a marine fish tank. The project uses an 18F4520 running from a 20Mhz xtal with the HS_1 fuse setting, and runs fine until recently, when one of the constant current LED drivers seems to miss-read the PWM value when fading down (the remain three drivers, including sharing the same PWM pin work fine). First thoughts were that the driver was faulty so I fitted a replacement but the issue still happens.
Checking the datasheet for the driver, the minimum PWM frequency is 100 Hz, which was set in the PBP code, but I've been advised by fellow fish keepers that the drivers perform better at higher frequency so I changed the variable value for the frequency from 100 to 1000 but found I got a warning stating that I need to changes the settings or reduce the number of PWM channels etc - anyway entering a value of 400 was the maximum that would compile without error. However on loading this to the PIC the temperature displayed on the LCD is screwed up, with varying values from 155c, 237, 568, 233, mostly random three digit values. Setting the frequency variable back to 100 and the temperature is displayed fine.
Here's the section of code for the temperature:
Code:
'Get and display the temperature
OWOUT DQ, 1, [$CC, $44] ' Start temperature conversion
OWOUT DQ, 1, [$CC, $BE] ' Read the temperature
OWIN DQ, 0, [temperature.LOWBYTE, temperature.HIGHBYTE]
temperature = temperature */ 1600
lcdout $FE,$D4+0,"TEMP ",dec(temperature / 100),$DF,"C"
Any ideas ?
Bookmarks