TEENSY LC PWM outputs don't all work

Status
Not open for further replies.

P Dobson

Active member
I have written some code to extract the engine instrument data from X-Plane 10. The program all works on PWM pins 3,4,6,9,and 10 but I get nothing out on pins 16,17,20,22 and 23.

I am checking the pin outputs with an oscilloscope. I tried pull up resistors, made no difference. The output pins just sit low all the time.

The code for all channels is the same so I don't understand why half the PWM channels work and the other half do not.

I have attached the code I wrote for this project.

Can any one throw any light on why only half the PWM channels output???
 

Attachments

  • Engine_instruments_2.ino
    4.5 KB · Views: 93
i guess the simulator could be returning 0 for those ports associated with "non working" PWMs.
with your scope you could verfiy PWM with analogWrite(23,128); for each pwm port
 
Thanks for your reply.

I have been using "TeensyControl" plug-in within X-Plane 10 to verify that the simulator is outputting valid and non zero data. I can confirm that all 10 channels from the simulator are giving valid data. I have verified all PWM outputs on a 'Scope and only the 5 on the low number pins on the Teensy LC are outputting PWMs from the Teensy LC. The high number pins are sitting permanently Low (0v).

I have swapped around the X-Plane parameters to different PWM channels but still only the low number pins output PWM.

Cheers, Pete.
 
it's possible something else in the sketch is messin' with those upper PWM pins? So to confirm your PWM pins aren't fried, you could write a small sketch that does analogWrite(pwmpinx,128); for every PWM pin and then use your scope to verify (or add attachinterrupt on pin 2 and count pulses when pwm pin is jumpered to 2)
 
OK, I am being dumb. I tried writing directly analogWrite(22, 128); for example and that worked. So I then tried writing to the 10 PWMs all fixed values. This did not work. I began to think that the Teensy LC could not deal with 10 off PWMs all at once.

So I rewrote the project (Same coding as before) and uploaded that. This time it worked. I think what I had done was I Mapped CHTP (Cylinder Head Temp Port) and CHTS (Cylinder Head Temp Starboard) and I think the engines were too cool to get onto the mapped area so ended up with a constant 0v. I also forgot to switch on the engine alternators so there was no generator current running i.e. 0v. Most of my initial testing was done on the Port engine only so I did not even start the Starboard engine initially. (thus no Oil_Temp_Stbd). This explains all the high No PWMs being at 0v.

So all working now, back to my simulator cockpit build and get these instruments installed in the panel. Should look good when finished.

Thanks Manitou, without your encouragement I probably would not have got to the bottom of what I was doing wrong.
 
Status
Not open for further replies.
Back
Top