Ive got a project that has some issues, what the project is suppose to do is have 2 pots that control 2 FET's via Software or Hardware PWM's to control LED light strings.
Here is the results
Trial 1 - Get a single unit to work, both Software and hardware work fine as a single unit with code for only 1 being used, the software version can use about any chip with a adc converter.
Here is some code that was working with
Now this is the software version of PWM, its low tech and maybe theres another way better for software PWM.Code:DEFINE ADC_BITS 10 ' A/D number of bits DEFINE ADC_CLOCK 1 ' Use A/D internal RC DEFINE ADC_SAMPLEUS 50 ' Set sampling ti TRISIO = %000101 ' AN0 & AN2 is Analog input CNT VAR byte POT1 VAR WORD POT2 VAR WORD CNT=0 AGAIN: ADCIN 0, POT1 ' Read Channel 0 data POT1 = POT1 / 256 if POT1 < 10 then POT1 = 0 ADCIN 2, POT2 ' Read Channel 0 data POT2 = POT2 / 256 if POT2 < 10 then POT2 = 0 RUNNER: if POT1 > CNT then GPIO.1 = 1 ELSE GPIO.1 = 0 endif if POT2 > CNT then GPIO.3 = 1 ELSE GPIO.3 = 0 ENDIF CNT = CNT + 1 if CNT > 255 then CNT = 0 if CNT = 0 then goto again GOTO runner end
----------------------------------
Here is my hardware version I am using a 12F683 for this one
Again this one works fine by itself.Code:DEFINE ADC_BITS 8 ' A/D number of bits DEFINE ADC_CLOCK 1 ' Use A/D internal RC clock DEFINE ADC_SAMPLEUS 50 ' Set sampling time in us ADCON0.7 = 0 ' Justify Result to 10 & 8 bit Side CCP1CON = %00001100 ' Set ADC Port RES1 Var Word ' A/D converter result TRISIO = %00000010 AGAIN: ADCIN 1, Res1 ' Read Channel 0 data if res1 < 10 then res1 = 0 ' Low Auto Shutoff HPWM 1, res1, 18000 ' PWM Pin, Setting, Frequency (20k Max) pause 25 goto again end
I did try to merge both into one chip and have both hardware and software but that didnt go so well, they interact with each other, im not sure why as the pins they use and code are seperate but it happens, and I erased the code that was messed up.
So what I would like is some sample code for dual PWMs that do not interfere with each other, I only have legacy 8bit processors right now (629, 675, 683, 4550) and although I do have a PicKit3 Available I am using pbp2.6 and mcs4. I will be getting PBP 3gold soon, perhaps in a couple of months and will have access to other chips then too.
So any ideas are welcome.





I ordered some of the 12f1572 's but since its been so long I've lost them and need to order more, I do have a PicKit3, hovever i need to order PBP3. I was going to order the Gold but I cant seem to find my discount link. there is a link that gives you $30 - 50 off but its been so long I've changed PC's and lost the link Can Anyone provide? anything cheaper than the list price would be good. thanks. Did I mention how hard it is to start this back up after a year of not programming and losing code notes! hehe. make backups!


Bookmarks