PWM over a  shift register 74hc595

Hi all, recently i come into this cool shifter register from philips. it's quite common, and maybe lot of you know how it works.

it's a fine multiplexer, and offcourse it work easy in digital mode. so all the 8 outpin can controller with 3 digital output on arduino.

now i want to take a step over and try to multiplexer an analogue signal. i'm sure there is a way to use PWM to recreate the analogue signal from the digital one. but still don't have any idea to do this. i'm sure someone did it before me ... so if you are out there pls drop me some suggestion :smiley:

tnx a lot :wink:

best
Nick

PWM is just setting a maximum duty cycle, and determining how long each output is on for that duty cycle. Say your maximum cycle time is 64, then using a loop counting up to 64, just compare the current cycle step to each duty cycle for each output, and set the bit appropriately on or off.

don't get it at all.

i just want find a way that let me set the multiplexer pin out like an analogue pin. that mean not only 0 or +5v but all the range beetween.
i can,as you say create the pwm system with code, but how use it with the shift register?

You said "that means not only 0 or +5v but all the range between." Flat out, NONE of the Arduino pins ever outputs anything but full LOW (ground) or full HIGH (+VDC) at any time. That's all they do.

A PWM signal is a quickly flickering signal that is LOW sometimes and HIGH sometimes. If you call analogWrite(5, 128), that's LOW for half of the time, and HIGH for half of the time.

To do it with a plain shift register like the 74*595, you'd say "here's your eight bits, some are HIGH!" and then say "here's all your eight bits again, now they're LOW!" really fast. But it won't be anywhere near as fast as the PWM pins do this same job.

There are output extender chips like the TLC5940 which offer similar capabilities, but you specify the PWM values to the chip, and it then starts doing the PWM signal without further help from the processor.

ok now i get it ;D

so your suggestion is not to stress up the processor, and let a external chip make the dirty work.

the final idea is to control some highpower-led (yes... i'm a sheep that follow the masses) so need 3*n (where n is number of the leds) to control some rgb leds.

it will be great if there is some chips out there that can create pwm signal on a wide power range (+24v / ground) under the control of the arduino 5v logic. off course with a power supply additional input.

again another question on pwm in general. image i'm using a pwm signal that is +5v for the 50% of time and gnd for the other 50%. I decide to use this pwm to control a led. image also that i'm using a duty cicle of 60hz. (if i'm not wrong, human eyes framerate are around 30fps) i have the same result of the normal HIGH digital signal. (the led is always on). Can i say that i'm using the half of power with the same result? or there is some micro fenomenal that waste power on other things, like parassite current?

tnx again ... any suggestion are welcome :slight_smile:

Yes, you're using half the power. The light may look like it's always on, but it's only on half of the time. It will be dimmer than being always on, but due to the way LEDs and eyeballs work, it probably will look closer to full brightness than half brightness.

Another method is Binary Coded Modulation (otherwise known as Bit Angle Modulation)....