Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

SPI to PWM conversion

Status
Not open for further replies.

InspectorGadget

Junior Member level 1
Joined
Oct 17, 2012
Messages
17
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,432
I'm working on a project involving LEDs and their wireless control.

My wireless transmitter is using the SPI protocol, but I want to convert this to PWM at the receiver end to control the LED driver. I know there are one or two ICs that can perform this conversion, and I've found a suggestion for doing it using a PLD, but they're about as clear as mud!

What I'd like to do though as a learning exercise is figure out the logic circuitry required to do this conversion. I'm in need of pointing in the right direction though because I'm very new to this. Basically my slave receives an SPI signal, and I need to convert this to a PWM signal to send to my LED driver. For starters say just to turn on and off the light.

Could anyone suggest where to begin, or what I should look at?
 

Your question isn't clear - you cannot send SPI over a wireless link as it requires at least 3 simultaneous direct connections.

If what you mean is your transmitter has SPI control, you have to send a suitable command to it along the SPI wires in order that a particular byte sequence is transmitted.
At the receiver, you have to analyze the byte and decide what PWM frequency/ratio it is asking for, then produce the PWM in a different circuit.

You will need some kind of 'intelligence' to produce the SPI to the transmitter and at the othe rend, to decode the command and produce the PWM. It doesn't sound difficult but I would suggest you look at a small microcontroller at each end. I prefer PIC devices but almost any IC family with a UART and PWM generator should work.

Brian.
 
Hi Brian, thanks for the reply.

The wireless section of this isn't too important for now. Basically my wake up radio receives data wirelessly which it decodes in hardware. From this I receive an SPI output with first some preamble info (a few bytes), then the actual data byte, then some CRC data.

What I'd like to do is use this byte of SPI data to somehow define the duty cycle of the PWM. If possible I'd like to avoid a microcontroller for the time being (I know it would be simpler) to create my PWM. Is there a neat way of doing this using logic gates and then control some type of PWM generator?

I hope I've explained it clearly. Thanks again.
 

A microcontroller can do this very easily. In logic gates it's fairly difficult.

You have to use several shift registers to convert the SPI data back into parallel. Basically, you wait for the SPI enable signal to go active then use the SPI clock to shift the SPI data into the shift registers. At the end of the data the enable signal should go inactive and you hold the bits in the shift register by holding them in latches. From there you can check your preamble and CRC and extract the PWM data.

There are several ways to generate PWM, probably the easiest is to load your PWM byte into a counter and use it to create a count up/down period. The period has to be less than or equal to the PWM repitition period. Using an SR Flip-flop or similar logic you can then start your PWM pulse at the beginning of the PWM period and stop it when the counter times out. That way, the counter determines the pulse width.

In pure logic gates you can probably do it in about 10 ICs, I'm not designing it for you though!

In an 8-pin PIC I could probably write it in 100 lines of code.

Brian.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top