
Originally Posted by
Darrel Taylor
AN4, ok.
Make ANSEL = %00010111
Darrel, can you confirm that I have understood the variables for SPWM_PIN right, and that I'm using the correct channels for a/d, as I only had 2 out of 4 outputs working right, and now made changes I get that high frequency noise from the armature (where as before it was a low growl, even with a 20 Mhz xtal)
I want to use the following pins on the 16F676 for inputs from 10K pots, and their corresponding PWM outputs
Pot 1 - Pin 13 - AN0 - controlling output on pin 8 - RC2
pot 2 - Pin 12 - AN1 - controlling output on pin 5 - RC5
pot 3 - Pin 11 - AN2 - controlling output on pin 6 - RC4
pot 4 - Pin 10 - AN4 - controlling output on pin 7 - RC3
so I've set up SPWM_PIN as
Code:
SPWM_LIST macro ; Define Pin's to use for SPWM
SPWM_PIN PORTC, 2, _DutyVar1 ; and the associated DutyCycle variables
SPWM_PIN PORTC, 5, _DutyVar2 ; Notice the underscore before variables
SPWM_PIN PORTC, 4, _DutyVar3
SPWM_PIN PORTC, 3, _DutyVar4
And have the main program as
Code:
Main:
ADCIN 0, DUTYVAR1
ADCIN 1, DUTYVAR2
ADCIN 2, DUTYVAR3
ADCIN 4, DUTYVAR4
GOTO Main
I'm assuming the value of ANSEL is incorrect as its ommitting that high frequency noise. Given the above info, which I hope is clear, what would be the correct value for ANSEL, or have I made another boo boo in assignig the pins ?
By the way, prior to the change I had it running really well on CH1 - you thought that on a 12F @ 4mhz the loco was slow.... wait to you see the video for it running on a 16F @ 20 mhz !! - its just amazing !!
Bookmarks