I've been messing around with some ws2812 LEDs and want to make a computer for my 18month old daughter. I've decided on a boxed up Raspberry PI with some WS2812 LEDs and some big round one-arm-bandit buttons I got from China. The buttons came with white LEDs but I found that some IOT modules neopixels fit nicely!
Now, it is theoretically possible to drive WS2812 LEDs direct from the PI but that uses the PWM system and I want to be able to play video and sound back whilst the LEDs are going so that's a non-starter.
So, I decided to use the i2c bus to send the LED info out of the PI and then to use a PIC16F to interface to the LEDs. I've not seen anything on the net that does this without external circuitry. Getting the timing right in a 16F is a challenge. However, at 20MHz it is possible to get the correct timings for the LEDs and loop through a buffer putting out the bits. I decided to use a PIC16F88 - I have a lot of them!
The main part of the problem is how to get each bit and turn the port on off, in a six cycle loop with different mark/space ratios for 0's and 1's. I faffed around a bit and got the capture compare/PWM module to do the actual pulses and a tight 6 cycle loop to do each bit for each byte. There is a small each byte has an extra pause between them but it doesn't seem to hurt.
The code accepts i2c data on address 0x24 up to 96 bytes can be sent. Data is sent out to the LED's on PORTB. No external parts needed except two pull up resistors for the i2c lines and the crystal can caps.
The i2c code is pretty simple and runs in a polling loop that waits for a start bit, then a valid address then just keeps reading bytes until a P bit comes along or the buffer is full. Then the number of bytes read are sent out the LEDs.
This should work with any i2c bus not just the PI.
If you'd like the code get in touch.
D
Friday, 1 April 2016
Sunday, 22 February 2015
A new step attenuator
It's been a few years now since I built this project and the signal generator is still going strong and getting plenty of use.
The step attenuator didn't fare so well though. I never did get round to boxing it up and I left it next to the damp wall in my workshop. Over the course of the winter and due to my not cleaning the flux off the boards thoroughly it has turned into a bit of a rotten mess.
It's probably possible to rescue it but it's never worked that well and the switches were pretty unreliable. So I had a look on ebay and saw this:
A switched attenuator with 0-127dB in 1dB steps. After some confusion (the ebay ad said it was TTL and had SMA connectors - it actually needs around 15V on the inputs and the connectors are TNC) I got started on a control circuit for it.
I've decided I want something simple but not too simple. It just needs up/down push buttons and a readout. I've added some nice features too:
The step attenuator didn't fare so well though. I never did get round to boxing it up and I left it next to the damp wall in my workshop. Over the course of the winter and due to my not cleaning the flux off the boards thoroughly it has turned into a bit of a rotten mess.
It's probably possible to rescue it but it's never worked that well and the switches were pretty unreliable. So I had a look on ebay and saw this:
A switched attenuator with 0-127dB in 1dB steps. After some confusion (the ebay ad said it was TTL and had SMA connectors - it actually needs around 15V on the inputs and the connectors are TNC) I got started on a control circuit for it.
I've decided I want something simple but not too simple. It just needs up/down push buttons and a readout. I've added some nice features too:
- fast up down if button held
- outputs only update after the buttons have been released for ~1/4 second to save on relay chatter
- outputs turn on / off individually - with low bits to high bits in turn - this to avoid sudden surges of current overloading supply
- outputs turn on / off individually in two passes - one for attenuators on one for attenuators off - this means that there is never a state where the attenuation is less than it should be to avoid overloading sensitive circuit
- outputs have series resistors bypassed by capacitors - this give a high current initially to help turn the relay on then a lower "hold current" to keep the relay on.
I bought some simple DC-DC converts off ebay for a few pounds (XTW-SY-8) and from Pomeroni I bought some tiny seven segment 4 digit calculator LEDs which look cute.
I knocked up a prototype first using a PIC uController and a Matrix Multimedia breakout board.
I wrote the software in C in the latest version of MPLab - this took a while to get installed and working but once installed is nicer to use than the older versions.
Next I put the circuit into KiCad and designed a board. The actual board I designed had a few mistakes:
- The labels for the attenuator outputs were reversed
- I'd misunderstood the attenuator and thought there were 2 x 64dB instead of 3 x 32dB
I've corrected these mistakes in the attached files
I've just bought a a laser printer and decided to use that to print the PCB layouts. I used inkjet transparencies and printed onto the rough side. I found that two passes through the printer gave a good enough contrast. Careful alignment of the paper on the first and second passes is key and give the ink time to set between passes to avoid smudges.
My first attempt was not great - I'd tried to be too greedy, passing very fine tracks between pins and there were a lot of bridged tracks and a few of the very fine tracks had breaks, also the pads were too small for drilling. On my second attempt I got a satisfactory board which worked first time - apart from the labels being wrong!
I placed the buttons and LED on the back of the PCB and intend to bolt that to the front panel with holes cut for buttons and LEDs.
Here's the MPLAB and KiCad (corrected) files: http://authorityfile.co.uk/NBSC/Home/OtherStuff
Wednesday, 24 March 2010
New C version software
Finally finished a new version of the software this time using an 18F525 running at 40Mhz (10MHz crystal with HSPLL engaged). The software is now in a mixture of C and assmebler and allows FM at 19.5KHz and upped the wobbulator updates to 39000 per second.
The new software is available at http://authorityfile.co.uk/NBSC/Home/OtherStuff
Here's a few pictures of it being used in anger to map the properties of the 10.7MHz input filter of my log-detector (an SA614 RSSI output with 2x 10.7MHz cermic filters).
They're interesting in that they show the harmonics generated by the DDS-60 daughterboard. These appear to be much better than the claimed 40dB down at about 55dB down - though this is just those that fall in the 10.7MHz region.
The traces are all with 10dB per division.
The slight sparkling on the pictures is due to the fact that the scan doesn't progress linearly but is a set of stepped frequencies. This isn't a problem but shows up noticably on a photo. However, a slower scan rate gives less "sparkly" pictures but I had to run these at 50Hz otherwise my shaky hands made the pictures blurred!
Dom
The new software is available at http://authorityfile.co.uk/NBSC/Home/OtherStuff
Here's a few pictures of it being used in anger to map the properties of the 10.7MHz input filter of my log-detector (an SA614 RSSI output with 2x 10.7MHz cermic filters).
They're interesting in that they show the harmonics generated by the DDS-60 daughterboard. These appear to be much better than the claimed 40dB down at about 55dB down - though this is just those that fall in the 10.7MHz region.
The traces are all with 10dB per division.
0-60MHz
0-20MHz
10-12MHz
The slight sparkling on the pictures is due to the fact that the scan doesn't progress linearly but is a set of stepped frequencies. This isn't a problem but shows up noticably on a photo. However, a slower scan rate gives less "sparkly" pictures but I had to run these at 50Hz otherwise my shaky hands made the pictures blurred!
Dom
Tuesday, 9 March 2010
All boxed up
After making some progress on re-writing the software in C I decided to take a break and do a bit of metal bashing. It's not perfect but at least now it powers itself and is less likely to break if I knock it over!
The front:
The innards:
The front:
Tuesday, 23 February 2010
Trying it out
I've spent far too much time recently writing software for this thing and not enough time holding a soldering iron. So last night after building the step attenuator I decided to try the thing out in anger.
I started this project to help me make a Spectrum Analyser. I started this ambitious project a few months ago but soon realised that I'd need a decent sig-gen / wobbulator if I was to have a chance of setting up and testing out any of the tuned circuits and filters in this thing.
Here's a few shots of it testing out one of the first components I built for the Analyser. It's a SA614 chip setup as a RSSI meter. Basically this is a linear to logarithmic converter, it should output a nice linear signal over a 90dB range...good enough for a basic analyser! The RSSI circuits I've made use an IF of 10.7Mhz and have a couple of ceramic filters to set this up (robbed from old radios).
The pictures are produced by using the Wobbulator function on the sig-gen. it is set to scan over 2MHz starting at 9.6 MHz. The SYNC output is fed to the scope's external trigger input and the wobbulator, via the step attenuator into the RSSI circuit's RF input. The RSSI output then goes to the scope's normal input.
I started this project to help me make a Spectrum Analyser. I started this ambitious project a few months ago but soon realised that I'd need a decent sig-gen / wobbulator if I was to have a chance of setting up and testing out any of the tuned circuits and filters in this thing.
Here's a few shots of it testing out one of the first components I built for the Analyser. It's a SA614 chip setup as a RSSI meter. Basically this is a linear to logarithmic converter, it should output a nice linear signal over a 90dB range...good enough for a basic analyser! The RSSI circuits I've made use an IF of 10.7Mhz and have a couple of ceramic filters to set this up (robbed from old radios).
RSSI Circuit
The pictures are produced by using the Wobbulator function on the sig-gen. it is set to scan over 2MHz starting at 9.6 MHz. The SYNC output is fed to the scope's external trigger input and the wobbulator, via the step attenuator into the RSSI circuit's RF input. The RSSI output then goes to the scope's normal input.
First Scan - too peaky!
At first glance I was very happy with this trace - well it proves the wobbulator is useful! There is about 0.8div of "passband ripple". That equates to almost 15dB! I could measure this by switching in the the attenuators until the tallest peak ended up where the dip is. There is about 350kHz bandwidth niceley centred on 10.7MHz. Again this was easy to measure by "tuning" the wobbulator until the edges of the trace just touched the left hand side of the screen.
The circuit has two 10.7MHz filters and as can be seen from the scans these are a bit peaky I've tried messing about with the circuit to produce a nicer passband but all it's done so far is make it an odder shape...however it's now a million times easier to experiment than it is using a normal siggen and graph paper. I can tack solder components in while its running and see the changes on screen in an instant!
Here's a shot after a bit of messing about...more theory needed I think!
Trace after messing with the circuit
Step attenuator
As there is no way of changing the amplitude of the signal produced electronically I've decided to add a "step attenuator". This is basically a box of switches that allow you to switch in a bunch of circuits to reduce the signal getting out.
I'd like to be able to get down to about 0.1uV so worked out that about 150dB should do the trick. I've ended up with a circuit with the following attenuators 1db,2,2,5,10,20,20,20,40,40. Anything bigger than 40dB would probably be too difficult!
Anyway I designed up a PCB and bought a bag of switches and last night knocked the thing up. The box is roughly made up out of PCB stock. It doesn't need to be too pretty as this will all sit inside another housing when its finished, it's really just for shielding.
It seems to work as expected (after a lot of working out resistor values). Anyway here's a few pics of the thing. I really need to take it to somebody else to tell me if it is working correctly as all my test gear is pretty ropey!
I'd like to be able to get down to about 0.1uV so worked out that about 150dB should do the trick. I've ended up with a circuit with the following attenuators 1db,2,2,5,10,20,20,20,40,40. Anything bigger than 40dB would probably be too difficult!
Anyway I designed up a PCB and bought a bag of switches and last night knocked the thing up. The box is roughly made up out of PCB stock. It doesn't need to be too pretty as this will all sit inside another housing when its finished, it's really just for shielding.
It seems to work as expected (after a lot of working out resistor values). Anyway here's a few pics of the thing. I really need to take it to somebody else to tell me if it is working correctly as all my test gear is pretty ropey!
I decided to use F-connectors for this as BNC connectors are starting to get a bit too expensive, the front panel connectors will still all be BNC.
Downloads
I've added a link to my other website on the left - this contains the most up to date schematics and software
D
D
Subscribe to:
Posts (Atom)