Learning verilog….

So it’s not as bad as you first might think. It turns out that real time logic isn’t much different from process logic. Tho I did fall at the first hurdle:

So apparently the file name has to be the same as the entity name and that needs to be the top level entity. Furthermore the module inside it needs to have the same name also.

oh, and ‘end module’ is actually ‘endmodule’, or it will fail to compile!

(This is in QuartusII FYI.)

Laser cutter update

So here’s a little update on my laser cutter,

I’ve moved over to a pre-written firmware, as writing the code for Arduino to receive and interpret the g-code was getting boring and why re-invent the wheel?

After a few mins of tweaking and some time using Inkscape to make the G-code, this is what I’ve  progressed to….

A primitive cut on my laser cutter - still needs some work.

A primitive cut on my laser cutter – still needs some work.

Still need to work on the focus and the speed settings.

Testing two axis stepper control on two A4988’s

So last night I breadboarded the two driver circuits and wrote some simple command line style Arduino Sketch.

Here’s the code,

#define stepPin 2
#define dirPin 3
#define enablePin 4
#define stepPin2 5
#define dirPin2 6
#define enablePin2 7
int incomingByte;

void setup()
{
pinMode(enablePin, OUTPUT);
pinMode(stepPin, OUTPUT);
pinMode(dirPin, OUTPUT);
digitalWrite(enablePin, HIGH);

pinMode(enablePin2, OUTPUT);
pinMode(stepPin2, OUTPUT);
pinMode(dirPin2, OUTPUT);
digitalWrite(enablePin2, HIGH);
Serial.begin(9600);
}
void loop()
{
if (Serial.available() > 0) {
// read the oldest byte in the serial buffer:
incomingByte = Serial.read();
// up
if (incomingByte == ‘U’) {
digitalWrite(enablePin2, LOW);
delayMicroseconds(10);
digitalWrite(dirPin2, HIGH);
for(int x=0;x<3200;x++){
digitalWrite(stepPin2, LOW);
delayMicroseconds(2);
digitalWrite(stepPin2, HIGH);
delayMicroseconds(80);
}
digitalWrite(enablePin2, HIGH);
Serial.println(“Moved up”);
}
if (incomingByte == ‘D’) {
digitalWrite(enablePin2, LOW);
delayMicroseconds(10);
digitalWrite(dirPin2, LOW);
for(int x=0;x<3200;x++){
digitalWrite(stepPin2, LOW);
delayMicroseconds(2);
digitalWrite(stepPin2, HIGH);
delayMicroseconds(80);
}
digitalWrite(enablePin2, HIGH);
Serial.println(“Moved down”);
}
if (incomingByte == ‘L’) {
digitalWrite(enablePin, LOW);
delayMicroseconds(10);
digitalWrite(dirPin, LOW);
for(int x=0;x<3200;x++){
digitalWrite(stepPin, LOW);
delayMicroseconds(2);
digitalWrite(stepPin, HIGH);
delayMicroseconds(80);
}
digitalWrite(enablePin, HIGH);
Serial.println(“Moved left”);
}
if (incomingByte == ‘R’) {
digitalWrite(enablePin, LOW);
delayMicroseconds(10);
digitalWrite(dirPin, HIGH);
for(int x=0;x<3200;x++){
digitalWrite(stepPin, LOW);
delayMicroseconds(2);
digitalWrite(stepPin, HIGH);
delayMicroseconds(80);
}
digitalWrite(enablePin, HIGH);
Serial.println(“Moved right”);
}
}
}

It receive’s a letter, U, D, L or R and moves the respective stepper motor one turn in that direction. Trivial but it’s a step forward (hehe).

While doing this I’ve had to learn a lot about how the Arduino handles power and how the power pins actually work. Feeding 5v into the 5v pin turns out not to be a good idea. A better thing to do (arguable the proper thing) is feed 12v to the Vin pin and use the on-board regulator. This also (I believe from the schematic) disables the 5v from the usb from the Arduino (meaning I don’t feed 20a into my USB port :D). One annoying thing I’ve noticed is that the Vin pin will output a voltage while running on USB. there is no protection diode on the Vin bus – there is a diode between the 2.1mm input jack and the Vin but tho.

Onwards and upwards I’ve also made a board up to hold the drivers and have output’s and things all nice and tidy, with pins for Vin, gnd, Vout and 5vin and GND to the Arduino, and then 2 6 way headers for stepper control and 2 4 way headers for the stepper motors. Here’s what it looks like now:

New driver board

New driver board (the breadboard is just a 5v rail while I change the code to use different stepping methods)

Next steps will be to continue working on the code , Might move to an Arduino Mega so i can use a touch screen too.

16th stepping stepper motor with A4988 driver carrier from Pololu

So in an effort to control the stepper motors more accurately I’ve invested in some Pololu Stepper motor driver carrier boards. This gives 2 advantages over a traditional H bridge arrangement,

  • Micro stepping,
  • Current limiting.

Using the diagram from here but with a few changes, I pulled ms1,2,3 to high to enable a resolution of 16 microsteps, and wired it to an Arduino for control.

#define stepPin 2
#define dirPin 3
#define enablePin 4
void setup()
{
pinMode(enablePin, OUTPUT);
digitalWrite(enablePin, HIGH);
pinMode(stepPin, OUTPUT);
pinMode(dirPin, OUTPUT);
digitalWrite(enablePin, LOW);
delayMicroseconds(10);
digitalWrite(dirPin, HIGH);
}
void loop()
{
digitalWrite(stepPin, LOW);
delayMicroseconds(2);
digitalWrite(stepPin, HIGH);
delayMicroseconds(80);
}

this simple code allowed me to achieve around 3.8 revolutions per second, or ~230rpm. Which is a lot more than in full stepping mode without jumping.

Running stepper motors on 12v

So today I’ve continued hacking an ATX PSU into a power supply for my laser cutter, and I thought I’ld give the stepper motor a try on the 12v bus.

I used the same code as in http://crazy-logic.co.uk/archives/314 but this time I managed to get it rotating with 2ms between steps, as opposed to 4ms on 5v supply. I have 200 steps per revolution so

1/200*0.004 = 1.25rps = 75rpm for 5v,
1/200*0.002 = 2.5rps = 150rpm for 12v.

This is an obvious improvement. This will be further improved I imagine after trying a different driving arrangement for the stepper motors with micro-stepping. I did try 1ms, however the stepper motor didn’t really appreciate the speed.

12v stepper motor arrangement

12v stepper motor arrangement

CNC router no more. I’ve decided….

… to make a laser cutter instead.

I’ve always wanted a laser cutter, but I’ve never really been able to afford one.

So i’m putting the CNC router on hold for the time being and building a laser cutter. It’ll have around a 1W laser and have a cutting bed of 600 by 800mm… which is quite big for a starter project.   I want to build it spending less than £300 on parts…. so cheaper than the CNC router too.

How hard can it be? Here’s a quick Google sketch up of my idea’s

my laser cutter

my laser cutter

 

 

Arduino based DMX DeMUX – Analogue – part 2

I realised I’ve left this project hanging a while now and that’s partly to do with he fact that the chips I was hoping to use didn’t arrive quickly then other things got in the way.

I’ve also hit upon two other snaggs,

  • The power supplied from the dimmers is not 10v, so this means adding in two power regulator circuits (one for 5v data and the other a 10v reference),
  • The chips will only do 0-5v, which obviously is no good for the 0-10v that’s required.

Never mind – this is still a project i’m working on – just a little more complex than I first thought.