Sunday, December 3, 2017

Getting Started with DS89C450 in Linux

It's been a few years since I got my DS89C450 chips with me. And now only I gonna give it a go with some cool projects. Since PIC and then Arduino became very famous, many hobbyists and embedded fans seems to be leaving the cool 8051 chips.

Oki... lets get to know about the DS89C450 chip. The best thing is about these DS89C4x0 microcontrollers by Maxim is the stable bootloader and they are very easy to program. As per the DS89C450 Datasheet the following are the exciting features of these ICs

  • Highest performing 8051 compatible microcontrollers.
  • Ultra high speed upto 33MHz and 32MIPS (Million Instructions Per Second)
  • 16kB/64kB Flash memory.
  • In-System programmable with Serial Port. (There are 2 full duplex serial ports)
  • 13 Interrupt sources including 6 External Interrupts.





Programming Hardware


There is a very good and informative application note from Maxim about the full technical details. However the basic Hardware setup would be like below,






The programming software will initiate bring down the chip to the programming mode by setting the DTR of the Serial Port to LOW, thus R1Out will be LOW and EA, PSEN will become LOW and RST will be HIGH. This will kick off the bootloader and the bootloader prompt will be transmitted through the Serial Port 0 of the chip.






And now we are good to load the hex code to the Chip. When the flashing finishes, the programmer will set the DTR of the Serial Port back to HIGH and the chip returns back to the running mode.


I have constructed the above circuit on a small dotboard and wired with the tiny wires uses for wirewrapped constructions. The construction is the same as above, except I have allocate a pin header for export the 4 I/O Ports and also facilitate for the 2nd Serial Port and, (of cause) 5V power regulator. And this makes the board a completed dev board.


    



Software in Linux

This is very important. In Windows there are pre-built software and it's very easy to use. The first thing I have done after building the circuit was (obviously) connecting the board to a PC with the aid of a USB to RS232 converter. I use minicom with Ubuntu 16.04

Run minicom -s and select Serial port setup and set the parameters. Make sure to select both hardware and software flow control as No. Save the configuration and select Exit. Hit the Enter Key and then you would see the banner from the bootloader.

CONNECTED TO LOADER SUCCESSFULLY

DS89C450 LOADER VERSION 2.1  COPYRIGHT (C) 2002 DALLAS SEMICONDUCTOR


I have used sdcc compiler for writing and compiling 80c450 code in Linux environment. Version 2.8.0 worked for me however. For loading I have used the perl script done by Vinu. However I had to make some minor changes according to my hardware setup.

import serial,time,sys,os
os.system("clear")
if not sys.argv[1:]:
    print "hex file not specified in command line argument\n\n"
    print "usage:\npython romloader.py filename.ihx\n\n"
    print "example:\n python romloader.py ledblink.ihx\n\n"
    sys.exit(0)
ser = serial.Serial('/dev/ttyUSB0',9600)
ser.timeout = 0.3
try:
    ser.setDTR(1)
except Exception,e:
    print "error open serial port: " + str(e)
    exit()
if ser.isOpen():
    try:
        ser.flushInput()
        ser.flushOutput()
        ser.write("\x0D")
        ser.write("\x0D")
        time.sleep(0.3)
        recbuffer = ser.read(80)
        list = recbuffer.split(" ")
        print recbuffer
        if '>' in recbuffer:
            print "CONNECTED TO LOADER SUCCESSFULLY"
            print recbuffer
        else:
            print "CONNECTION ERROR"
            ser.setDTR(0)
            ser.close()
            sys.exit(0)
        ser.write("K\x0D")
        time.sleep(0.1)
        ser.write("L\x0D")
        f=open(sys.argv[1],"rU")     
        hexcontent = f.read()
        f.close()
        ser.write(hexcontent+"\x0D")
        k = ser.read(200)
        print k
        ser.setDTR(0)
        ser.close()
    except Exception, e1:
        print "error communicating...: " + str(e1)
else:
    print "cannot open serial port "


A simple LED Blink program

Ok below is the test program to blink an LED connected to the P0 port.

#include "sdcc_reg420.h"

void delay(unsigned long int i) //delay function
{
    while(i != 0){
        i--;
    }
}
void main(void)
{

   while(1){
        P0^=255;    //PORT0 = PORT0 XOR 1
        delay(189000); //calling delay
    }
}








Compile the code with sdcc



sdcc led.c

and this will generate led.ihx hex file.

And load the ihx to the chip with the above script

python ./prog.py led.ihx




And.. if everything goes well, the LEDs connected to the Port 0 should blink!!


Await for more and troubleshooting tips.

Tuesday, November 14, 2017

Getting started with Altera MAX7000 CPLDs

While hunting for vintage and NOS electronic components in Colombo... I managed to find a huge lot of ICs, Chips and sockets from a friendly sales person. He been so generous to offer me the entire stock for a very low price :)

And the stuff been hanging around for some long time in my lab and thought to give a go for Altera MAX7000 (EPM7064SLC-44) the one I got with a PLCC44 package. The data sheet can be found in here

There are are many good things about this series of chips, specific to the EPM7064 the following are the interesting features,

1. EEPROM based, so no need of external flash devices to keep the configuration.

2. Built in JTAG BST test circuitry.

3. 5.0V Operation.

4. 1250 Usable gates.

Since I already had one of these Altera USB blasters with me I was doing some research to hook up the chip with the JTAG device and start using it and I have come across with this great article by Bil Herd on Hackaday.

Based on Bil's design I have developed the basic stuff on a vero board.



It was not that hard to wire and solder the stuff on vero board, however it would be useful to keep the max7000 datasheet and the the plcc44 pinouts handy.

First I decided to wire with a laminated copper wire but soon I realized thats not gonna work.. so decided to move with the 30 AWG wire.

Testing time..

Used my DMM (Continuity check) to make sure there are no any short circuits, and all the Vcc and GND connection and JTAG connections are in place with the correct pins of the IC.

After all the checks completes, connected the USB blaster to the board and then to my Ubuntu laptop. I user Altera Quartus II V13.0 SP1








 
Detecting JTAG device.


1. In linux, dmesg is useful to identify the USB blaster is properly connected and working.

2. If everything goes well, jtagconfig command should identify the device.





So all went well and the device detected form the jtagconfig and also with the Quartus II.



But, in order to do more stuff, I need to have a clock source. For testing I used this NXP 74LVC1GX04 module and then a quick and dirty setup of LEDs on a breadboard.




Bingo... things started working and I could blink the LED in 1 Hz frequency.

What next?

Further.. hoping to install an On-board Oscillator as a Clock source and add some more components like SSD displays Switches and LEDs.

I have used KXO-100 As the clock source.



And 4 LEDs, DIP switches and also 2 SSDs to do more things with this board. And of cause a PIN header for IO.





For the initial tests I used Verilog with Quartus II

Some examples,

LED Blink,






































BCD Counter

































Await....

Await for all the schematics and Code.






Saturday, October 28, 2017

Simple LED Flasher with 2N2222

This would be the most simple LED flasher circuit ever. But the theory behind the operation is not that simple. The principle behind this circuit is the negative resistance of a transistor.

Negative Resistance is the way a transistor behaves Voltage and Current are inversely proportional to each other. While a usual circuit follow the Ohm's law. However there is no such thing called minus resistance but the term came based on the negative slope of the relevant V-I curve.



In this configuration the base of the 2N2222 is open the C? should be 330uF 16V. The 1K resister is charging the capacitor the capacitor until the Base-Emitter voltage is set to trigger the transistor to operate in the negative slope of the V-I curve, thus the the current starts flow through Emitter to Collector and the LED lights. This discharges the capacitor and drop the Base-Emitter voltage and again the transistor will off, and the capacitor starts charging again. This continues and the LED will stay blinking.

Just to increase the LED blink frequency I have changed the C? to 220uF and also used 15 Ohm resistor between the Q1 and the LED for protection.




Couple of Zero Ohm has also been used instead of jump wires (this is very useful when constructing on a breadboard, will be discussing more about zero ohm resistors in a later post)




This circuit requires exact 12V DC, and it is better to experiment with other general purpose NPN transistors and PNP ones doesn't work with this. Since the voltage is important, make sure to measure the supply voltages (in my case, the 12V supply was throwing 18V :( and the circuit didn't work)

You can try adding a 10K pot between the +Ve supply and the 1K resistor for voltage adjustments as well.
















































































Friday, October 13, 2017

AN6610 Motor Speed Controller.

I been collecting some NOS stock of good old Linear ICs and found a couple of AN6610 ICs. It's been pretty hard to locate a data sheet (In English) however managed to construct a simple motor speed controller within 5 minutes of effort (on a breadboard)

The IC,





AN6610
AN6610




AN6610 comes in TO-126 Package and pretty easy to use.

The data sheet I found from here


As per the data sheet, the schematic would be,



The quick and dirty construction worked well, except there is a start-stop-start pattern observed at low speeds.


Rs, I have used a 5K POT and worked fine.

Here are some pics I have taken while playing around and quick and dirty construction of the above circuit.

Components:

Unfortunately I couldn't find 470 Ohm resistor and the 22uH Inductor. I used 330 Ohm resistor instead. However it is good to do experiments by changing the value of this.








The construction on a breadboard:

AN6610