Friday, May 14, 2021

Program Blue Pill with CKS32F103C8T6 using UART

 I needed a Blue Pill for a project. Got a few on ebay, but I couldn't find genuine STM32 ones in Europe. So I got ones with the compatible CKS32F103C8T6 chip.

I have never programmed a Blue Pill of any kind, so I don't really know how it is supposed to work. Programming with ST's UART tool didn't work for me, it didn't like the identity of the board. I instead got success using stm32flash, which can be found here https://sourceforge.net/projects/stm32flash/ .

I used  some generic USB-to-UART cable, which identifies as being "Prolific USB-to-Serial". Make sure that the UART dongle works by doing a loop test.

To program the chip on the Blue Pill, follow these steps:

  1. On Blue Pill set jumper for"boot 0" to 1.
  2. Connect UART GND (black) to G on Blue Pill
    UART 5V (red) to 5V on Blue Pill
    UART RX (white) to A9 on Blue Pill
    UART TX (green) to A10 on Blue Pill
  3. From command line, run:
    stm32flash -g 0x8000000 -b 115200 -w gd32f1_generic_boot20_pc13.bin COM4
    where COM4 is whatever com-port the UART has attached to, and the bin-file is whatever bin-file you want to upload.
    There seems to be some problem with paths and stm32flash, so I run everything from the same folder.
  4. On Blue Pill set jumper for"boot 0" to 0.
  5. Push reset button on Blue Pill.
  6. Done! 

Tuesday, March 30, 2021

ABC80, Saving and loading programs using soundcard

As a cheap and quick way to get going, using an ABC80 (by Swedish Luxor), you can use a pc with a soundcard to save and load programs, like you normally would do using a tape station.


1 Cable

You need a cable with a 3.5mm audio, stereo plug in one end, and a 5 pin DIN in the other end. The cable should be wired like shown in the image:
 

Cable should be connected like this 

2 Audacity

I use Audacity as audio software on the PC. I'm sure there are plenty of other programs that are usable.
Set up audacity like in the images:
  • Mono sound
  • Set inputs and outputs so you hear output in a pair of headphones, and inputs so a mic gets picked up by the soundcard
  • Max levels on record and playback

 3 Save

  1. Enter a program in the ABC80. For example
    10 print "Hello world!"
  2. Insert 3.5mm audio plug into mic jack and DIN-connector in ABC80
  3. Start recording in audacity
  4. In the ABC80, enter:
    save cas
  5. Watch the waveform get recorded. 
  6. When the waveform ends, stop recording. 
  7. Delete the whitespace before and after the waveform.
  8. Save as .WAV-file.
Saving waveform in Audacity

4 Load

  1. Load wave file in audacity
  2. Insert 3.5 mm audio plug into headphone jack on PC and DIN-connector in ABC80.
  3. On ABC80, enter load cas
  4. Start playback in Audacity
  5. When the program has finished loading, ABC80 will give a new prompt or an error message
  6. list or run the program
Loading program from audio file in Audacity

Good Luck!




Friday, March 27, 2020

Amiga 500 PSU repair

I have an Amiga 500 PSU which is a bit unstable. Sometimes my Amiga 500's don't start when using this PSU.




I measured the voltages of the PSU (when connected to the Amiga) and the 5V rail was a bit low, and slowly rising. When the voltage was under 4.8, the Amiga wouldn't start. So in order to troubleshoot, I started with drawing a schematic of the PSU. The schematic is a work in progress, I change it as I find errors, so the best version is at GitHub: https://github.com/archstanton1862/A500-PSU .



So, in accordance to the schematic references, I measured the parts that are involved in the 5V regulators feedback: 5V reference was 5.008V, excellent in other words.
5V R2 = 1.500k
R4 = 4.702k
Internal reference R1 = 1.498k
R5 = 4.700k
These resistors show signs of getting hot, so I measured them swell.
R6 = 179.8
R8 = 179.9



The first idea I had was to replace the output transistor. It was difficult to find the exact replacement , so I ordered a D45H11G (instead of the original D45H2). This did not change the faulty behaviour.





Finally I tried swapping the regulator IC, SG3524,  to a new one. I didn't think this would work, but actually it did. Voltage in a running Amiga 500 was measured to 4.93V and this was enough for stable activity.

PSU with replaced regulator IC (SG3524)



Sunday, March 22, 2020

Amiga 500 Floppy Panasonic JU-257A606P modification

I modified a couple of floppy drives (Panasonic JU-257A606P) to work in an Amiga 500. I found a description of how this is done here http://eab.abime.net/showthread.php?t=30944 , but one of the drives had a different version PCB than the one in the link. So I figured out how to modify that one as well, and for reference I am showing the necessary steps below:



Wednesday, July 31, 2019

EPSON SMD-400 Repair - Amiga 500 Floppy Drive





The old Amiga 500 I got had a non working floppy drive. The span up, abnormally fast, and then stopped. When there was no disk in the drive, the magnetic head twitched back and forth, which I think is normal behaviour.


First thing to try is changing electrolytic capacitors. To get to the caps, the drive's disk tray needs to be dismantled. It took me a while to figure it out, but its done like this:

Mounting bracket and casing of drive has been removed (easy). If you need to use force, you are doing it wrong.




Step 1.
Remove lock-screw and spring, marked in the first image.
Push the disk ejection button to release the upper disk holder mechanism. Push it forwards-downwards to release it.






Step 2.
Remove springs marked in second image.
Push disk eject mechanism forward to release it.






Step 3.
Replace the five caps, marked C08, C09, C10, C11 and C05. I used EMLF160ADA100MD73G as replacement caps.

After this the drive works as expected again.

Caps removed



New caps in place


Saturday, July 20, 2019

Amiga 500 power supply repair

I bought a cheap Amiga 500 as non functioning. I knew that the power supply was non-functioning, so I started there.

Amiga 500 PSU
The inside looked OK, but there where several signs of somebody tampering with it.
The bottom part of the PCB had some funny looking solderings with a lot of gunky-looking flux residue.


Bottom side of PSU PCB. Some gunky looking flux residue can be seen to the bottom right, top right and top left.
The board is marked 871, 6L78, A 500.
When I removed the strange looking solder I discovered that one of the pads to the transformer didn't have a connection at all! Maybe it was loose and I sucked it into the solder sucker.

Anyway, I soldered some wire to the transformer and touched up the bad looking solder joints, and the PSU worked nicely after that.

Repaired transformer connection behind the fuse



Transformer pads with solder removed. Pad with no connection to it to the right of the large mounting hole in the middle.



I made a note of the electrolytic capacitors on the board, so that I can order new ones and recap it.


No capsC(uF)U(V)diam (mm)
322255
147006.315
23302510
147002516

When I have recapped the PSU, I will properly clean off all the old flux.


Monday, February 8, 2016

40m Ham radio receiver using a NE602

I've been building a circuit I found in "Experimental methods in RF design". It's a 40m AM/SSB/CW receiver using a NE602. I've been doing some experimentation to get the receiver working, especially with the local oscillator. In the book, they recommend a toroid wound coil, but I couldn't get that to oscillate. Finally I made an air wound coil, which worked. But since the coil was wound "mid air", it picked up even the smallest vibration in the surroundings, leading to a very unstable oscillation. I solved it by shoving a roll of paper inside the coil. I also worked some on getting the antenna input filter better matched.
It receives between 6.9 and 7.4MHz, but it hasn't got a lot of selectivity, which I will try to solve somehow. Also, I want to interface the LO to a frequency counter, so I need to build a buffer amplifier to not load down the oscillator.
Here are some images of the receiver and the schematics so far:
Receiver circuit board. Antenna input, with attenuator pot seen to the left. Tuning caps on the right.
Receiver with shielding in place. Tuning knobs to the left.
Receiver diagram.

Interfacing old telephone to PIC

The old telephone has two ingoing lines. These are balanced inputs, one at about 48V on  hook, in respect to the other. I will call the 48V line positive and the other negative, even though they sometimes are the other way around.
To make a simple and quick conversion circuit, I want to use a PICS general I/O, with a max input of 5V. The phone's positive line has three levels when dialing with pulses. 48V (hook on) , ~10V (hook off) and 0V low level during dialing. I want the PIC to see the two low levels as 0, and the high level as 1. I also need to protect the PIC against over voltage  during ringing, when the line goes through 110V AC with 30Hz frequency. During ringing I also need to protect against negative voltages.
Since the PIC has ESD protection in the form of diodes on the IO's, I could rely on them to do the voltage protection. This seems like a bad idea though, since they are poorly speced in the datasheet and the data sheet advice against using them this way. The built in diodes has a voltage drop of about 0.6V. To beat these diodes I put in a BAT54 in the same fashion This is a Schottky diode with 0.35V forward voltage drop, so that it shunts overvoltage before the internal diodes.
Here's what the interface looks like:
Phone line to PIC I/O interface

and the board so far:
Interface and PIC along with a row of LEDs. Phone line connectors to the left, top and bottom.

I've tested having the PIC flash an LED when detecting high/low level, and there seems to be no spurious errors with this setup. Next step is to start counting pulses with the right time spacing, and register what number is dialed.

Thursday, January 7, 2016

Old telephone conversion

I found an old rotary phone on a flea market and decided toplug it in. My land line goes through the cable modem, which doesn't support this old way of entering the phone number. What I need todo is convert the pulses of the phone to dual tone multi frequency tones. Step one is to reverse engineer the old phone interface. I connected a scope to the connected phone plug and got these signals:
On hook.
Off hook, with speach.


Receiving ringing.

Dialling a "4".
My initial thoughts is to connect these signals to a microcontroller to count pulses, and then let the microcontroller inject the right dialling tones on the line. First thing to do is to solder phone plug connectors to a perfboard to see if I can convert the 48V signals to logic levels (3.3V on 5V tolerant ports is my thought).






Friday, June 5, 2015

Annoying Beeping Prank Circuit

Since i quit my old job last week, and I had the last day more or less alone in the office, I made a few loving pranks on my coworkers. One of them was a simple circuit based on a 555 timer. The circuit is simply a pulse oscillator with a couple of minutes between pulses. The circuit is seen here:
556 Pulse oscillator
The 1M Ohm resistor sets outputs high time together with the capacitor. The 100 Ohm resistor and capacitor sets the low time. This setup gives the inverse output of what I wanted to drive the buzzer (should be any buzzer with internal oscillator that can be driven by 9V), but it needed to be that way to keep power consumption low. If the resistors where swapped, the DIS-pin would discharge the power rail through the 100 Ohm resistor instead of the capacitor. To invert the output i used a second 555 as an inverter. In this configuration the circuit drew 8mA, which would give a couple of days use with a 9V, 580mAh battery.
Google told  me there was a CMOS-based low power version of the chip, TLC556. That chip was pin compatible and used up 0.3mA. This gave a run time of about 80 days which I was very happy with.
The circuit simply gave a short, loud beep every few minutes. I hid it in my colleagues flower pot and it took him quite a while to find it.. ;)
Implemented circuit

Sunday, April 12, 2015

MIDI2VC+, a MIDI driven Voltage Controller

The MIDI2VC+, v2, is finally finished. These are the implemented features:
MIDI2VC+, v2, primary side.

MIDI2VC+, v2, secondary side.

  • 5 octaves 1V/octave VC output
  • 3V gate output
  • Low note priority
  • Filters channel number, plays any MIDI-note regardless of channel
  • MIDI input and USB-MIDI input. Prioritise USB if both are connected.
  • Reset button
  • Pitch bend, 2 semitones in each direction
  • Input voltage 8-35V (high input voltage may need heat sink on regulators)
  • 5us trigger output
  • Powers USB-keyboard
  • USB interface tested on Korg MicroKEY 25
  • RCA jacks as outputs. Used RCA wires are easy to find very cheap, and jacks can easily be salvaged from scrapped audio equipment.
  • Both code and hardware is open source licensed to CERN OHL v.1.2.
The PCB needs two straps. The MIDI input to the micro controller has no connection. Pin 4 on the optocoupler needs to be strapped to pin 24 on the micro controller. Also, the optocoupler needs to be powered from the 3V3 rail instead of the 5V. Before the optocoupler is mounted, one needs to cut out pin 6 and the pad from the pull-up resistor right besides it. When the optocoupler is mounted, strap a wire from pin 6 to the 3V3 rail.

Cutout below optocoupler.
Anyone is welcome to edit the layout files to fix the straps. I'm not going to do another version of the PCB at the moment. Eagle files and source code is available here.



Monday, March 16, 2015

Tinker-Box á la Bob Pease

I made a tinker-box, as recommended by Bob Pease in Troubleshooting Analog Circuits. It's simply a box of banana jacks connected to various resistors and capacitors. There is one rotary switch connected to resistors of values 10-66kOhms. There is a second rotary switch connected to capacitors of values 10p-1uF. Finally there is also a 100k potentiometer and a ferrite bead. Not much else to say about it other than that it's of great use when experimenting with op-amps. I used it when  i built last posts EMC-meter.
Inside of tinker-box.

Panel-side of tinker-box.

Saturday, March 14, 2015

EMC sound detector

I saw this youtube video a while ago. It shows an EMC meter using a piezoelectric summer, a coil and a fet.I thought that instead of  coil, I could do the same thing using a semi-rigid cable for a magnetic field probe, like the ones Doug Smith describes. I have previously written about a field probe that I have used with an oscilloscope. The signal from the probe that I have seen has been on the order of 10mV, max. This is far to low to make a summer sound. The summer needs a at least a few volts of signal to sound enough.
So to make this circuit work I needed to produce a gain of at least a few hundred. I started out trying to do this with an uA741. With a gain-bandwidth product of 1MHz, I could at most produce a gain of 100 at 10kHz, which was a bit weak. After that I tried using a . It had a better gain-bandwidth product of 3MHz, but I had a lot of problems with lock up and oscillations.
Finally I solved the gain-bandwidth issue using two op-amps, the LM358 (two amplifiers in one package).  Since the signal is low, and we are interested in the AC-signal, I AC-coupled the feedback loop in both amplifier stages. Final circuit looks like this:
EMC sound detector
EMC sound detector, actual build.

There was some trial and error and usage of what components was at hand. To determine the maximum gain of the second stage, I used a potentiometer where the 270 ohm resistor is now. I turned the potentiometer to just below the point where the circuit started to oscillate. The circuit is sensitive enough to sound out fields from, for example a cell phone, but the sound volume isn't that high. I think the circuit can achieve higher gain with a smaller cap on the output (22uF now). I would need to put a higher resistor after it though, to keep this stage from filtering out low, but audible frequencies.

Tuesday, March 10, 2015

New PCB's and Books

Got the new PCB's for the MIDI2VC+ v2 from OshPark yesterday. I'm pretty happy with how they look. I managed to cram in everything on the top layer. The bottom layer is only ground, not a single trace or component.
New PCB's from OshPark
Also, I got some nice books from dad for my birthday. It's:"Build your own transistor radios" by Ronald Quan and "Experimental methods in RF design" Wes Hayward et. al. These will most certainly give some nice ideas for electronics projects. I've already started reading Quan's book, and it's really interesting.
Some nice birthday books from dad

Sunday, March 1, 2015

Velleman KSR6 kit, error in silkscren

Last post I talked about the KSR6 Velleman kit and that the robot didn't turn when closing in on objects. After troubleshooting the robot for a while, I finally found the error. The voltage divided node at U4 +in and U3 -in lay at nearly 6 volts, instead of the expected 3 volts (which in retrospect is odd, this voltage should instead be closer to 2V, only explanation I can come up with is that that R8 had a bad connection, but who knows?). This made the integrator U3 integrate only voltages over the node, which was almost nothing... After inspecting the schematics and the layout, it was obvious that the silkscreen component markings had mixed up R8 and R10. Switching them made the robot work the expected way.
This might not be true for all PCB versions. This PCB was marked 21-885. If you are uncertain, measure the voltage of pin 3 or 13 of IC1. It should be  close to 3V. If resistors are placed wrong, voltage will be closer to 6V.

Monday, February 23, 2015

Velleman Ladybug Robot, KSR6

My daughter got a Velleman KSR6 kit for Christmas, and the other day she finished it's assembly. We tested it out and it's motors ran as they should, but the robot didn't turn when closing in on objects. I sighed a bit and started troubleshooting. When looking into the design I started thinking it actually was quite cool. It's control system was made from four op-amps. No digital circuitry at all. I can't publish the whole schematic here, since it's copyright Vellemans, but it can be found in the manual in the above link. I made a simplified Spice simulation of the circuit and made some comparing measurements. I'll briefly explain what the different parts do and compare simulations to measurements:

Simplified LT-Spice schematic drawing

 U1

A pulse of about 1ms is fed through the DC-blocking C1. The pulse in the actual design comes from the IR-diode, which picks up reflected IR from the IR-LED.
U1 is simply a non-inverting amplifier which is AC-coupled using C2. C2 makes the gain roll of to unity at DC.

The big pulse is from the IR-LED, for triggering purposes. The small pulses are from the U1+ node, a high pass filtered pulse.

And the same filtered pulse in LT-spice. Very similar to reality. 
U1 amplifies the positive going pulse to look like this:

Amplified pulse, almost rails the output of U1.

Amplified pulse of U1, looks very similar when simulated.


U2

This is an emitter follower with a diode on the output and a bleeder resistor to ground. U2 can only source current to node U3+. After U3+ is charged,the voltage is kept high by C3 and R4 for a while.
The small pulse of node U3+ is not what we expect.
The simulation shows what I expected. A high step that slowly bleeds out through R4.

So the problem is probably in node U3+. Perhaps a bad connection to the cap or a bad cap. I'll look more into it. In the following sections I'll just explain what is supposed to happen and show the simulations.

U3

Is a slow integrator that keeps the output high while U3+ is discharging. If the original incoming pulse (at U1+) is smaller than some threshold, U3o won't have time to integrate to any significant level before U3+ is discharged. U3o then stays low.
U3o when it has had time to integrate to a high voltage level.

U4

This is a comparator. If U3o is over 3V, U4o drops to it's lowest level. If U3o is below 3V, U4o kicks up to it's max output. 

Complementary outputs of U3 and U4


U3 and U4 has complementary voltage levels at their outputs and the are used to drive the H-bridge to one of the robots motors, making the motor reverse for a while when the robot receives a big echo from it's IR-receiver. This makes the robot back out and spin 90 degrees before continuing forward.

Wednesday, February 4, 2015

MIDI2VC+, demo with low noise

Last post I wrote about the noise problems when running the MIDI2VC+ with a mock up synthesizer. I suspected that the I2C bus picked up noise and crosstalk from the USB bus, as they where routed very close each other. I also looked at emitted noise on the board and saw that there where lots of emissions at the USB connector. To see the emissions I used a looped semi-rigid coax with a slit. The coax was connected to a scope with a 50Ohm standard coax:
Electromagnetic emissions sniffer made from semi rigid cable
I captured  image on the scope showing background levels and levels from USB connector:
Background emissions vs USB connector emissions
I patched the board by cutting the I2C traces that passed the USB connector, soldered wires instead. This made the noise go away completely, as can be heard in the demo.
MIDI2VC+ board with I2C bus patched with white cables.



 The only problem left right now is that, from no known reason, the I2C transmission process stops prematurely, before it has completed. If I don't find the cause, I may add a time out and resend feature that may solve the problem.