Two puzzling problems..
lardom
Posts: 1,659
The first puzzle is why did I have to use cognew to set up PWM with the counters. (The examples I've seen used repeat loops.) If that is normal then OK.
The second puzzle is the transistor I used in the circuit drew current even though the Propeller Demo board was switched off!
When the prop was grounded to the emitter and the i/o pin was connected to the npn base I could measure voltage between the emitter and the collector.
Just to test I used a Quickstart board to see if there was resistance between an i/o pin and ground. I measured around 12.6 megohms. I got a resistance measurement for both boards.
The second puzzle is the transistor I used in the circuit drew current even though the Propeller Demo board was switched off!
When the prop was grounded to the emitter and the i/o pin was connected to the npn base I could measure voltage between the emitter and the collector.
Just to test I used a Quickstart board to see if there was resistance between an i/o pin and ground. I measured around 12.6 megohms. I got a resistance measurement for both boards.
Comments
That's why the COG is needed to reset the counter periodically (according to the PWM frequency)!
There is a trick available which uses 2 counters to generate a PWM and then you don't need the COG to maintain the PWM frequency.
If you want more pins that output a PWM it's simply more practical to start a PWM object which generates the PWMs old-style.
@MagIO2, I'll take your advice. I'm trying to create a pwm power supply which can be controlled by a potentiometer for a brushless motor. I've gotten satisfactory speed with DC and a step pattern but learning to control the supply voltage is harder than I thought.
The basic idea is easy: Have 2 counters -connected to 2 pins- which have the same frequency but are out of phase. With an external xor the phase-shift generates a PWM. The trick mentioned in the thread avoids the external xor somehow - but I don't remember.
@kuroneko,:thumb: 'The riddler'? You've helped to solve a few of mine. Thanks for the link.
The way I connected the transistor was to connect the battery negative to the emitter, the collector to the breadboard ground rail and the battery positive to the breadboard positive power rail. I attached the i/o pin to the npn base through a resistor and grounded the Prop to the emitter. It made sense to me. On the same breadboard I built a 3 1/2 H-bridge that worked perfectly. I'm still searching for my error.
Searching for solutions to my current project has been tough because of hurricane Sandy. Realizing now that I could have initialized the counters with OBJ instead of using the cognew command...I wish I had not asked.
This is a great forum. I always end up with a net gain in knowledge beyond my original questions so thanks for not brushing my questions aside.