Replacing STC MCS-51? - Page 1
Forum section: electronics / projects

author: Gall
author_rank: Frequent Contributor
timestamp: August 29, 2011, 03:03:23 pm
content: Hello,I have a Chinese CNC display board like this:. Unfortunately it misses pulses. This is due to incorrect technique they're using - they poll GPIOs. I want to fix them but this cannot be fixed in software.I'm too lazy to make a completely new board so I decided to replace the microcontroller. The MCU is STC12C5A08AD, a cheap MCS-51 one in TQFP44. It basically has MCS51 compatible pin layout with only two power pins and two xtal pins, everything else is GPIO. Pin 16 is GND, pin 38 is +5V VCC and pins 14 and 15 go to a 24 MHz xtal. I'm looking for a CPLD or something that can be soldered to this board instead of this MCU. Another MCU with 5 hardware counters would be nice but I'm afraid there's no MCU that has counter inputs at matching pins. (I haven't traced all the pins yet but inputs go somewhere near 8-11-13 edge of the chip).Can someone please recommend a chip? Does it exist at all?

author: tycz
author_rank: Regular Contributor
timestamp: August 30, 2011, 04:38:35 am
content: Quote from: Gall on August 29, 2011, 03:03:23 pmNo, doesn't exist.

author: Gall
author_rank: Frequent Contributor
timestamp: August 30, 2011, 07:13:54 am
content: Ok, another opportunity to hijack is to replace these 74HC14s with latches. It were nice to use something like 14-pin 16V8 eqivalent but this doesn't exist. Maybe small and fast 14-pin PIC would do the trick?..

author: tycz
author_rank: Regular Contributor
timestamp: August 30, 2011, 03:18:16 pm
content: Why do have to fix this with a drop in replacement part? Do you have one board or many?The STC part is already quite fast, and is not running at full speed. They claim to operate up to 35 MHz. (want to try it?). To add or swap with another 8 bit MCU will not really result in any significant performance gain. I don't know any STC part with hardware USB - does this have a software USB controller or is something amiss?

author: Gall
author_rank: Frequent Contributor
timestamp: August 31, 2011, 09:34:10 am
content: The problem is, no microcontroller is able to count short pulses in software in a reliable way. One has to use at least a 1:2 prescaler (flip-flop) to make pulses long enough, or better a fully hardware bidirectional counter.STC running at 35 MHz would have only about 150 kHz sampling rate if the software is highly optimized because it has to count 5 inputs at once. Thus it can miss pulse that is shorter than 10 us. And it misses.Plan A: Remove STC and place a CPLD instead, implement everything in hardware.Plan B: Remove two 74HC14s and place a CPLD instead, make hardware counters.Plan C: Throw this board away, take a CPLD and build my own design. But this board has lots of nice transistors to demux LEDs, why throw them away?Plan D: Fit Cypress PSoC somewhere, probably instead of STC. It's programmable peripherals are good enough to implement 5 hardware counters.Plan E. Remove two 74HC14s and fit 22V10 instead, turning them into 1:2 prescaler. (Or fit something else and make 1:4, 1:16 or programmable prescaler).Plan F. Prescale the signal before this board. (Inconvenient).Any suggestions?This part does not have any hardware USB. Looks like no software USB, too. This "USB" port is directly wired to the MCU and looks like it isn't USB at all, they just used an USB connector for something like debug port. My first guess was that it's RS232 but it does not go to RX and TX pins. I never tried to connect it to USB - I'm afraid it's 5V instead of 3.3 V.

author: tycz
author_rank: Regular Contributor
timestamp: September 01, 2011, 05:39:59 pm
content: If you don't mind the loss of resolution then dividing the pulse by two or four sounds to me like the easiest way to solve this problem. You could remove the two 74HC14 and solder wires from the pads to a small daughter board containing the division logic + schmitt triggers. At least that is how I would approach it.If you want it to be 100% reliable, future proof (higher speeds?), etc. then you really have to re-design it from scratch. Maybe keep the LEDS + transistors and replace the processor with a CPLD or whatever is most familier to you.Some other options are to run the whole system at a lower speed or replace it with a system of higher quality (ie. one that hasn't been cost-reduced to the point where it barely functions).

author: Gall
author_rank: Frequent Contributor
timestamp: September 01, 2011, 07:49:18 pm
content: If I divide the frequency by 2, nothing bad will happen. I'll still be able to count every pulse by counting level transitions instead of pulses. (I suspect that it will even work with old firmware). But I'll be able to poll much slower (I'll get rid of short pulses).If I divide frequency by 4, I won't lose any resolution. I have no less than 200 steps per mm and display has 0.01 mm resolution. Ok, counting every second pulse is still Ok.I do not want to hook wires instead of 74HC14, looking for a better way to do that. Unfortunately there are no 14-pin programmable logic devices. (I analyzed the possibility of using small 14-pin MCUs just to divide the frequency but they aren't faster than STC). One of the best ways is to solder two dual-row connectors instead of 74s and place a daughterboard on them. To make things simplier, I'll put a single 22V10 on this board. (So bad it has one side with all inputs so I can't use direct pin-to-pin connection without vias on the daughterboard).Ok, I had a sheet of flexible 0.1 mm PCB material somewhere. Maybe I'll etch an adapter from it.Also I probably have to rewrite the firmware anyway; I suspect that it is poor designed and I can do it better.