Posts with «logic» label

Hackaday Prize 2023: Building a Relay ALU

There’s much truth in the advice that, to truly understand something, you need to build it yourself from the ground up. That’s the idea behind [Christian]’s entry for the Re-engineering Education category of the 2023 Hackaday Prize. Built as an educational demonstrator, this is a complete arithmetic-logic unit (ALU) using discrete relays — and not high-density types either — these are the big honking clear-cased kind.

The design is neatly, intentionally, partitioned along functional lines, with four custom PCB designs, each board operating on 4-bits. To handle a byte-length word, boards are simply cascaded, making a total of eight. The register, adder, logic function, and multiplex boards are the heart of the build with an additional two custom boards for visualization (using an Arduino for convenience) and IO forming the interface. After all, a basic CPU is just an ALU and some control around it, the magic is really in the ALU.

The fundamental logical operations operating upon two operands, {A, B} are A, ~A, B, ~B, A or B, A and B, A xor B, can be computed from just four relays per bit. The logic outputs do need to be fed into a 7-to-1 bit selector before being fed to the output register, but that’s the job of a separate board. The adder function is the most basic, simply a pair of half-adders and an OR-gate to handle the chaining of the carry inputs and generate the carry chain output.

3D printed cable runs are a nice touch and make for a slick wiring job to tie it all together.

For a more complete relay-based CPU, you could check out the MERCIA relay computer project, not to mention this wonderfully polished build.

 

The HackadayPrize 2023 is Sponsored by:

Spit Out VGA with Non-Programmable Logic Chips

It’s not uncommon to bitbang a protocol with a microcontroller in a pinch. I2C is frequently crunched from scratch, same with simple serial protocols, occasionally complex systems like Ethernet, and a whole host of other communication standards. But VGA gets pretty tricky because of the timing requirements, so it’s less common to bitbang. [Sven] completely threw caution to the wind. He didn’t just bitbang VGA on an Arduino, but he went one step further and configured an array of 7400 logic chips to output a VGA signal.

[Sven]’s project is in two parts. In part one, he discusses choosing a resolution and setting up the timing signal. He proceeds to output a simple(-ish) VGA signal that can be displayed on a monitor using a single gate. At that point only a red image was displayed, but getting signal lock from the monitor is a great proof of concept and [Sven] moved on to more intricate display tricks.

With the next iteration of the project [Sven] talks about adding in more circuitry to handle things like frame counting, geometry, and color. The graphics that are displayed were planned out in a simulator first, then used to design the 7400 chip configuration for that particular graphic display. It made us chuckle that [Sven] reports his monitor managed to survive this latest project!

We don’t remember seeing non-programmable integrated circuits used for VGA generation before. But bitbanging the signal on an Arduino or from an SD card slot is a great test of your ability to calculate and implement precise timings with an embedded system. Give it a try!


Filed under: video hacks
Hack a Day 16 Oct 00:01

Review – Iteaduino Lite “nearly 100% Arduino-compatible” board

Introduction

Over the last year there have been a few crowd-funded projects that offered very inexpensive Arduino-compatible boards. Frankly most of them weren’t anything out of the ordinary, however one of them is quite interesting due to the particular design of the board, and is the subject of this review.

An established company Iteadstudio ran a successful Indiegogo campaign last December to fund their Iteaduino Lite – Most inexpensive full-sized Arduino derivative board”. Having a spare US$5 we placed an order and patiently waited for the board. Being such a low price it was guaranteed to raise the funding – but was it worth the money? Or the effort? Possibly.

The board

In typical fashion the board arrived in bare packaging:

 The Iteaduino Lite isn’t that surprising at first glance:

To the new observer, it looks like an Arduino board of some sort. Nice to see all those GPIO pins with double breakouts. No surprises underneath:

The URL on the bottom is incorrect, instead visit http://imall.iteadstudio.com/iteaduino-lite.html. Looking at the board in more detail, there are some interesting points of difference with the usual Arduino Uno and compatibles.

The USB interface is handled with the Silabs CP2102 USB to UART bridge IC:

The next difference is the power circuitry – instead of using a linear voltage regulator, Itead have used a contemporary DC-DC converter circuit which can accept between 7 and 24V DC:

Furthermore, the entire board can operate at either 5V or 3.3V, which is selected with the slide switch in the above image. Finally – the microcontroller. Instead of an Atmel product, Itead have chosen the LogicGreen LGT8F88 microcontroller, a domestic Chinese product:

And there are only two LEDs on the Iteaduino Lite, for power and D13. The LED on D13 ins’t controlled via a MOSFET like other Arduino-compatibles, instead it’s simply connected to GND via a 1kΩ resistor.

Getting started with the Iteaduino Lite

The stacking header sockets will need to be soldered in – the easiest way is to insert them into the board, use an shield to hold them in and flip the lot upside down:

Which should give you neatly-installed headers:

Watch out for the corners of the board, they’re quite sharp. Next, you need to install the USB driver for the CP2102. My Windows 7 machine picked it up without any issues, however the drivers can be downloaded if necessary.

Finally a new board profile is required for the Arduino IDE. At the time of writing you’ll need Arduino IDE v1.0.5 r2. Download this zip file, and extract the contents into your ..\Arduino-1.0.5-r2\hardware folder. The option should now be available in the Tools > Board menu in the IDE, for example:

From this point you can run the blink example to check all is well. At this point you will realise one of the limitations of the Iteaduino Lite – memory. For example:

You only have 7168 bytes of memory for your sketches – compared to 32, 256 for an Arduino Uno or compatible. The reason for this is the small capacity of  …

The LogicGreen LGT8F88 microcontroller

This MCU is a Chinese company’s answer to the Atmel ATmega88A. You can find more details here, and Itead also sells them separately. The LGT8F88 offers us 8Kbyte of flash memory of which 0.7KB is used by bootloader, 1 KB of SRAM and 504 bytes (count ’em) of EEPROM. Apparently it can run at speeds of up to 32 MHz, however the LGT8F88 is set to 16 MHz for the Iteaduino Lite.

According to Logic Green, their LGT8F88 “introduce a smart instruction cache, which can fetch more instructions one time, effectively decrease memory accessing operations“. So to see if there’s a speed bump, we uploaded the following sketch – written by Steve Curd from the Arduino forum. It calculates Newton Approximation for pi using an infinite series:

//
// Pi_2
//
// Steve Curd
// December 2012
//
// This program approximates pi utilizing the Newton's approximation.  It quickly
// converges on the first 5-6 digits of precision, but converges verrrry slowly
// after that.  For example, it takes over a million iterations to get to 7-8
// significant digits.
//
// I wrote this to evaluate the performance difference between the 8-bit Arduino Mega,
// and the 32-bit Arduino Due.
// 

#define ITERATIONS 100000L    // number of iterations
#define FLASH 1000            // blink LED every 1000 iterations

void setup() {
  pinMode(13, OUTPUT);        // set the LED up to blink every 1000 iterations
  Serial.begin(57600);
}

void loop() {

  unsigned long start, time;
  unsigned long niter=ITERATIONS;
  int LEDcounter = 0;
  boolean alternate = false;
  unsigned long i, count=0;
  float x = 1.0;
  float temp, pi=1.0;

  Serial.print("Beginning ");
  Serial.print(niter);
  Serial.println(" iterations ...");
  Serial.println();

  start = millis();  
  for ( i = 2; i < niter; i++) {
    x *= -1.0;
    pi += x / (2.0f*(float)i-1.0f);
    if (LEDcounter++ > FLASH) {
      LEDcounter = 0;
      if (alternate) {
        digitalWrite(13, HIGH);
        alternate = false;
      } 
      else {
        digitalWrite(13, LOW);
        alternate = true;
      }
      temp = 40000000.0 * pi;
    }
  }
  time = millis() - start;

  pi = pi * 4.0;

  Serial.print("# of trials = ");
  Serial.println(niter);
  Serial.print("Estimate of pi = ");
  Serial.println(pi, 10);

  Serial.print("Time: "); 
  Serial.print(time); 
  Serial.println(" ms");

  delay(10000);
}

For a baseline comparison, an Arduno Uno R3 completes the calculations in 5563 ms:

… and the Iteaduino Lite completed it in 5052 ms:

So that’s around a 10% speed increase. Not bad at all. The LGT8F88 also has the requisite GPIO, SPI, and I2C available as per normal Arduino Uno boards. You can download the data sheet with more technical details from here. Frankly the LGT8F88 is an interesting contender in the marketplace, and if Logic Green can offer a DIP version at a good price, the ATtiny fans will have a field day. Time will tell.

Power Circuit

The DC-DC circuit promises 5V output, with up to 24V DC input – so we cranked the input to 24V,  put a 1A load on the 5V output – and put the DSO over 5V to measure the variations – with a neat result:

So no surprises there at all, the Iteaduino Lite gives you more flexible power supply options than the usual Arduino board. However an eagle-eyed reader notes that a few of the capacitors are only rated at 25V – especially the two right after the DC socket/Vin. You can see this in the schematic (.pdf). So take that into account, or drop your Vin to something more regular such as below 12V.

Conclusion

The Iteaduino Lite is an interesting experiment in bargain Arduino-compatible boards. However we say “why bother?” and just get a Uno R3-compatible board.

At the end of the day – why bother with this board? For a little extra you can get boards with the ATmega328P or 32U4 which gives you 100% compatibility. Nevertheless, this was an interesting experiment. Full-sized images are available on flickr. And if you enjoyed this article, or want to introduce someone else to the interesting world of Arduino – check out my book (now in a third printing!) “Arduino Workshop”.

Have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, or join our forum – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

The post Review – Iteaduino Lite “nearly 100% Arduino-compatible” board appeared first on tronixstuff.

Tronixstuff 30 Jan 23:01

Various 1 Hz Oscillator Methods

Introduction

During the fun and enjoyment of experimenting with electronics there will come a time when you need a nice 1 Hz oscillator to generate a square-wave signal to drive something in the circuit. On… off… on… off… for all sorts of things. Perhaps a metronome, to drive a TTL clock, blink some LEDs, or for more nefarious purposes. No matter what you need that magic 1 Hz for – there’s a variety of methods to generate it – some more expensive than others – and some more accurate than others.

A few of you may be thinking “pull out the Arduino” and yes, you could knock out a reasonable 1 Hz – however that’s fine for the bench, but wild overkill for embedding a project as a single purpose. So in this article we’ll run through three oscillator methods that can generate a 1 Hz signal (and other frequencies) using methods that vary in cost, accuracy and difficulty – and don’t rely on mains AC. That will be a topic for another day.

Using a 555 timer IC

You can solve this problem quite well for under a dollar with the 555, however the accuracy is going to heavily rely on having the correct values for the passive components. We’ll use the 555 in astable mode, and from a previous article here’s the circuit:

 And with a 5V power supply, here’s the result:

As you can see the cycle time isn’t the best, which can be attributed to the tolerance of the resistors and capacitor C1. A method to increase the accuracy would be to add small trimpots in series with the resistors (and reduce their value accordingly by the trimpot value) – then measure the output with a frequency counter (etc). whilst adjusting the trimpots. If you’re curious about not using C2, the result of doing so introduces some noise on the rising edge, for example:

So if you’ve no other option, or have the right values for the passives – the 555 can do the job. Or get yourself a 555 and experiment with it, there’s lots of fun to be had with it.

Using a GPS receiver module

A variety of GPS modules have a one pulse per second output (PPS) and this includes my well-worn EM406A module (as used in the Arduino tutorials):

With a little work you can turn that PPS output into a usable and incredibly accurate source of 1 Hz. As long as your GPS can receive a signal. In fact, this has been demonstrated in the April 2013 edition of Silicon Chip magazine, in their frequency counter timebase project. But I digress.

If you have an EM406A you most likely have the cable and if not, get one to save your sanity as the connector is quite non-standard. If you’re experimenting a breakout board will also be quite convenient, however you can make your own by just chopping off one end of the cable and soldering the required pins – for example:

You will need access to pins 6, 5, 2 and 1. Looking at the socket on the GPS module, they are numbered 6 to 1 from left to right. Pin 6 is the PPS output, 5 is GND, 2 is for 5V and 1 is GND. Both the GNDs need to be connected together.

Before moving forward you’re probably curious about the pulse, and want to see it. Good idea! However the PPS signal is incredibly quick and has an amplitude of about 2.85 V. If you put a DSO on the PPS and GND output, you can see the pulses as shown below:

 To find the length of the pulse, we had to really zoom in to a 2 uS timebase:

 Wow, that’s small. So a little external circuitry is required to convert that minuscule pulse into something more useful and friendly. We’ll increase the pulse length by using a “pulse stretcher”. To do this we make a monostable timer (“one shot”) with a 555. For around a half-second pulse we’ll use 47k0 for R1 and 10uF for C1. However this triggers on a low signal, so we first pass the PPS signal through a 74HC14 Schmitt inverter – a handy part which turns irregular signals into more sharply defined ones – and also inverts it which can then be used to trigger the monostable. Our circuit:

 and here’s the result – the PPS signal is shown with the matching “stretched” signal on the DSO:

So if you’re a stickley for accuracy, or just want something different for portable or battery-powered applications, using the GPS is a relatively simple solution.

Using a Maxim DS1307/DS3232 real-time clock IC

Those of you with a microcontroller bent may have a Maxim DS1307 or DS3232. Apart from being pretty easy to use as a real-time clock, both of them have a programmable square wave output. Connection via your MCU’s I2C bus is quite easy, for example with the DS1307:

Using a DS3232 is equally as simple. We use a pre-built module with a similar schematic. Once you have either of them connected, the code is quite simple. For the DS1307 (bus address 0x68), write 0x07 then 0x11 to the I2C bus – or for the DS3232 (bus address is also 0x68) write 0x0E then 0x00. Finally, let’s see the 1 Hz on the DSO:

Certainly not the cheapest method, however it gives you an excellent level of accuracy without the GPS.

Conclusion

By no means is this list exhaustive, however hopefully it was interesting and useful. If there’s any other methods you’d like to see demonstrated, leave a comment below and we’ll see what’s possible. And if you made it this far – check out my new book “Arduino Workshop” from No Starch Press.

In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column? And join our friendly Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

The post Various 1 Hz Oscillator Methods appeared first on tronixstuff.

Tronixstuff 31 Jul 14:07
1 hz  555  74hc14  astable  clock  clocks  digital  ds1307  ds3232  em406a  gps  logic  pps  timebase  tronixstuff  ttl  tutorial