Why won't this create PWM?

Alec_t

Joined Sep 17, 2013
15,117
I started with a 5K resistor and it wouldn't even start producing a PWM signal. I went down to a 330 ohm resistor and that brought a 100 percent duty cycle down to a 10 percent. Even a 100 ohm massively dropped the duty cycle.
Well, the test has established that high resistance is the factor preventing the full range of PWM duty cycle. I'm surprised that is the case, since an analogue input on a MCU will usually accept a source impedance up to about 10k before significant loss of A/D conversion accuracy, if I remember correctly. I'd be suspicious that the input port has sustained damage?
I'm not fluent in C or PIC, so can't comment on the uploaded code.
 

geekoftheweek

Joined Oct 6, 2013
1,429
Just a few thoughts...

Your PICs clock will be 1 MHz by default. I didn't see OSCCON set to 2 MHz anywhere in your program. That would explain your PWM not being the right speed.

Section 18.1 of the datasheet lists 2.5k as the maximum impedance for analog sources. Even with that it should still work somewhat as I would assume the 4500 of your TPS would be at idle and 700 would be to the floor. I would think it would start to work around half to 3/4 throttle give or take a little.

You really shouldn't need the diode. The PIC should not back feed anything to the TPS. Unfortunately your PIC may be the source of the problems.. Maybe try an ADC pin on port B and see if there is a difference there.

Edit... something isn't making sense in my head. What engine and transmission are you connecting to? Your username has me curious....
 
Last edited:

Thread Starter

CumminsSuburban

Joined Sep 18, 2022
12
Just a few thoughts...

Your PICs clock will be 1 MHz by default. I didn't see OSCCON set to 2 MHz anywhere in your program. That would explain your PWM not being the right speed.

Section 18.1 of the datasheet lists 2.5k as the maximum impedance for analog sources. Even with that it should still work somewhat as I would assume the 4500 of your TPS would be at idle and 700 would be to the floor. I would think it would start to work around half to 3/4 throttle give or take a little.

You really shouldn't need the diode. The PIC should not back feed anything to the TPS. Unfortunately your PIC may be the source of the problems.. Maybe try an ADC pin on port B and see if there is a difference there.

Edit... something isn't making sense in my head. What engine and transmission are you connecting to? Your username has me curious....
Ill change the OSCCON and see what changes. I will also try a different PIC altogether and on a different port.

So this is a project I started on a few years ago. Its been put on the backburner quite a few times as I renovated my house and of course the kids are always a priority. Its a 2000 4x4 suburban. Originally had a 6.0 gas engine and I installed a 6.7 cummins with an allison transmission. It has parts from just about every make you could imagine. Its a real frankenstein. The engine is actually out of a generator lol.

307265769_1224297515093944_1914954503414786803_n.jpg307418385_824676422235192_1575609071131556039_n.jpg307730937_487208099941316_747726681730479893_n.jpg308030273_1462386737614422_3435265852910191232_n.jpg
 

geekoftheweek

Joined Oct 6, 2013
1,429
Nice build. I was guessing Ford (pardon my language) for the TCM as they like to use PWM for sensors. My experience with Allison is limited to trailer spotters at work. What is the TCM out of? None of the ones I have worked on have PWM inputs. I am wondering if one is an output instead. It seems weird to measure both 12 and 5 on inputs from another ECU. 5 sounds right, but 12 doesn't.
 

Thread Starter

CumminsSuburban

Joined Sep 18, 2022
12
It was pretty simple really. The PIC's analog input was working with a low (100ohms max) potentiometer, but would not work with anything with more resistance. Even though I set the trisa register as an input, i did not specify which pin with trisabits. Once I did that, it worked perfectly. It was confusing and throwing me for a loop when it worked to begin with, so it didn't occur to me that this was a possibility until one of you guys recommended to check it out.

I was also able to tweak the settings and get the proper 133HZ that i needed. Thanks everyone!
 
Top