Forfatter Mads Chr. Olesen

31 aug

0 Comments

Measuring high DC supply voltage with an Arduino

Af

For my home-monitoring setup I would like an Arduino to measure the supply voltage it is getting from a DC battery UPS (Uninteruptible Power Supply). Unfortunately (actually by design, but that’s another story), the power supply is 24V, which means it will put out anywhere from 21.3V-29.8V (according to the manufacturer), which is far too much to measure with the Arduino’s 0-5V input range. For simplicity’s sake, lets assume we want to measure a 20-30V voltage. The immediate answer is to use a voltage divider, which will bring a voltage in the 0-30V range into the 0-5V range. The general formula for the resistor divider is:

    \[V_{out} = \frac{R_2}{R_1+R_2} \cdot V_{in}\]

We want V_{in} = 30 to give V_{out} = 5, so

    \[\frac{5}{30} = \frac{R_2}{R_1+R_2}\]

resistordivider Now, just as a sanity check we should calculate the current of the resistor divider, to make sure we’re not converting too much electricity into heat. Ohm’s law gives us

    \[ I = \frac{U}{R}\]

which in this cases gives

    \[ I = \frac{30}{12000} = 0.0025 A = 2.5 mA\]

No problems there. This works okay, but we lose a lot of precision, as only ~1/3 of the Arduino’s range is actually used: the Arduino’s ADC has 1024 different readings between 0-5V, so when reading the 0-30V range the precision is just about 30V / 1024 \approx 0.03 V over the range. If only we could move the lower bound, so that 20V would map to 0V on the Arduino. A wild Zener Diode appears! One use of a Zener diode is as a voltage shifter. voltageshifter Zener diode voltage shifter. This work is licensed under the Creative Commons Attribution 3.0 License, https://en.wikipedia.org/wiki/File:VoltageShifter2.png. The closest Zener diode I could find was an 18V of the BZX79 series. This resulted in the following circuit: zener-voltage-divider which I hacked into my Arduino box. Hacked supply monitoring Now, theoretically the formula for translating an voltage at the Arduino to the supply voltage should be:

    \[Vcc = V_{in} / (4700/(4700+6800)) + 18 = V_{in} \cdot 2.4468 + 18\]

I then did some quick measurements of various input voltages and the resulting voltage at the Arduino pin:
Input voltage Arduino pin
18V 0.32V
20V 1.16V
26V 3.60V
28V 4.41V
29V 4.81V
Plot it into a spreadsheet, create a graph and add a linear regression gives: Now, this formula is a bit different compared to the theoretical one, mainly in the Zener diode drop. However, the datasheet for the BZX79 actually has the 18V C-type (\plusminus 5\%) as between 16.8-19.1V, so this is well within spec. Since this is just a one-off, I’m happy to just use the measured formula, as this will be more accurate. The final precision should be 12V / 1024 = 0.012V. The current should be around I = \frac{U}{R} = 30V/11500 Ohm \cdot 1000 \frac{mA}{A} = 2.6mA, which again is ok.

Gemt under: Extern, HAL9k

Tags: ,

17 jun

0 Comments

Roomba 500-series Easy Scheduling using an Arduino

Af

DSC_0879
I have a iRobot Roomba 500-series vacuum cleaner robot, but without any remote, or command center or anything; alas, I have to push a button everytime I want the cleaning revolution to start :-(

But no more! It turns out the Roomba can be programmed, quite easily, to schedule automatically, and all you need is:

  • 1 Arduino
  • 2 wires

The Roomba actually supports a serial protocol, the iRobot Roomba 500 Open Interface Specification, that allows remote control, driving, sensoring, and scheduling.

Finding the serial port

Remove the plastic cover. It is easiest to remove the vacuum bin, and carefully pry it off with a screwdriver.
DSC_0882DSC_0884

There should be a 7-pin plug, on the right side. It has the following pinout:

Roomba serial pinout

Roomba serial pinout

Program the Arduino

Use this sketch (download: roombaschedule.ino):


/*
Set a schedule on an iRobot Roomba 500 series, using just an Arduino.
Mads Chr. Olesen, 2015.
*/

const byte currentDay = 3;
// 0: Sunday, 1: Monday, 2: Tuesday, 3: Wednesday, 4: Thursday, 5: Friday, 6: Saturday
const byte currentHour = 2;
const byte currentMinute = 58;

// Schedule
const byte SUNDAY = 0x01, MONDAY = 0x02, TUESDAY = 0x04, WEDNESDAY = 0x08, THURSDAY = 0x10, FRIDAY = 0x20, SATURDAY = 0x40;

const byte daystorun = SUNDAY | MONDAY | WEDNESDAY | FRIDAY;
const byte times[14] = {
3, 0, // Sunday time
3, 0, // Monday time
3, 0, // Tuesday time
3, 0, // Wednesday time
3, 0, // Thursday time
3, 0, // Friday time
3, 0, // Saturday time
};

const int ledPin = 13;

void setup() {
Serial.begin(115200);
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, 0);

Serial.write(128); //Start
delay(1000);
Serial.write(131); //Safe mode, turns off Roomba light
delay(1000);
Serial.write(128); //Start, back to passive mode
delay(500);

//Set day time
Serial.write(168);
Serial.write(currentDay);
Serial.write(currentHour);
Serial.write(currentMinute);
delay(500);

//Set schedule
Serial.write(167);
Serial.write(daystorun);
for (int i = 0; i < 14; i++) {
Serial.write(times[i]);
}
}

void loop() {
digitalWrite(ledPin, 1);
delay(1000);
digitalWrite(ledPin, 0);
delay(1000);
}

You need to modify the variables at the top: set currentDay, currentHour, currentMinute according to the present time.
The pre-programmed schedule is to clean at 03:00 on Sunday, Monday, Wednesday and Friday. You can change this if you wish, by altering the daystorun and times variables.

If you don't modify the schedule, the Roomba should start automatically after 2 minutes.

Put it all together

You should now have a partially undressed Roomba, and a programmed Arduino. Now it is time to connect them. With both unpowered, connect the following:

  • Arduino GND to Roomba ground (pin 6)
  • Arduino TX (pin 1 on e.g. Uno) to Roomba RX (pin 3)

It should look like this:

DSC_0886

Now, the moment of truth. Press the "CLEAN" button on the Roomba, the light should go on. Plug in the USB for the Arduino. The Roomba light should turn off briefly, and after a few seconds the Arduino should blink it's LED. The schedule is now programmed, all done!

Gemt under: Extern, HAL9k

Tags: ,

06 maj

0 Comments

Indkaldelse til Ordinær Generalforsamling i Hal9k torsdag 2014-05-15 kl. 19:30

Af

Følgende er dagsordenen til den ordinære generalforsamling i foreningen HAL9k torsdag 2014-05-15 kl. 19:30 på Sofiendalsvej 80, 9200 Aalborg SV.

Inden generalforsamlingen er der fællesspisning ca. kl. 18.30. Tilmelding til spisning (menu/pris ikke kendt endnu, forventet max 50,-) foregår på https://doodle.com/xgcy9i9nd77s95z6 af hensyn til antallet.

Dagsorden:
1. Valg af ordstyrer.
2. Valg af referent.
3. Valg af to stemmetællere.
4. Bestyrelsesformanden og kassereren aflægger beretning, samt præsenterer planer for den kommende sæson.
5. Kassereren fremlægger det reviderede regnskab til godkendelse.
6. Forslag fra bestyrelsen eller medlemmerne, herunder vedtægtsændringer, behandles.
  – Forslag om nedsættelse af kontingent fra sidste generalforsamling:
100kr pr. md, (75kr for stud.).
7. Behandling af eksklusionssager.
8. Valg af revisor.
9. Valg af bestyrelse.
10. Valg af op til to suppleanter.
11. Behandling af indkommende forslag.

Indkomne forslag skal være bestyrelsen i hænde senest syv dage før generalforsamlingen.

Vi hackes ved,  

Bestyrelsen Hal9k

Gemt under: Projekter

03 apr

0 Comments

LulzBot Unboxing

Af


Gemt under: Projekter

17 jan

Kommentarer lukket til Reparere billige Denver Wake-up lampe

Reparere billige Denver Wake-up lampe

Af

Jeg havde to billige wake-up lamper fra Harald Nyborg der begge fejlede med samme symptomer: lyset var permanent tændt så snart strømmen var sat til, i stedet for at kunne slukkes og dæmpes. Grunden til nr. 2 blev købt var at nr. 1 fejlede efter garantien udløb, og til 200,- kunne det jo knapt betale sig at kigge på det. Da nr. 2 fejlede med samme symptom blev jeg stædig og irriteret over kun at kunne lave “brug-og-smid-væk”.

Hvor svært kunne det være at reparere noget billigt Kina-skrammel? Ikke ret svært viste det sig. Skidtet blev åbnet, og viser ret tydeligt hvor meget kvalitet man får for ikke ret mange penge:
Billigt print
Efter lidt konsultation af nogle af de mere elektronik-kyndige fik vi lokaliseret fejlen til en Triac der nok var brændt af. Desværre havde producenten valgt at slibe teksten af, så det var umuligt at se hvilken chip det var (sådan noget svineri!) — det virkede dog heldigvis med en helt standard BT137. På den ene lampe var der også brændt en modstand af: den var helt forkullet, men heldigvis kunne vi se på den anden hvilken modstand det var.
Ny triac

Efter at have loddet ny triac og modstand på, virkede lamperne som nye 🙂

Kan det betale sig at reparere billigt Kina-skrammel der er gået i stykker? Måske ikke økonomisk, til gengæld risikerer man at lære noget. Og så er det jo ret fedt at kunne fixe ting selv, i stedet for kun at kunne købe og smide væk!

Gemt under: Projekter

14 jun

1 Comment

PrintrBot Jr getting closer to working state

Af

Yesterday our PrintrBot Jr made its first useful prints!

DSC_0078

It has taken quite some effort to get to this stage, mostly because I knew nothing about 3d-printers when we started the project, and the original builders were out of town (but have now returned).

DSC_0059

We have made quite some modifications to the printer, mostly inspired by this blog post. Specifically we have (as documented on our wiki):

  • Upgraded belts to GT2, in our case with a 20-tooth pulley, all ordered from 3dnielsen.dk (although the GT2 belt seems quite expensive). This has definitely improved our accuracy, now the X- and Y-axis are at a nice even 80 steps/mm, as calculated by the very awesome RepRap Calculator.
  • Replaced some of the LM8UU ball bearings on the Y-axis because they were very unstable. This was probably the most important modification, although I don’t know if there is a difference in quality between the old and the new bearings. We still use the old bearings on the X-axis, they seem okay.
  • Added cork mufflers to the motors. I doubt this is essential or even provides much benefit on the Printrbot Jr because the motors touch the chassis at multiple points, but they are cheap and can be retro-fitted with little effort.
  • Made sure the circular ball bearings were properly tightened such that the middle part, that is not supposed to turn (as I learned), does not turn. Additionally, add wafers to get the bearings height aligned with the belts.
  • Replaced the Z-axis threaded rod with a metric one: This is an almost too easy upgrade to not do, as an M8 rod fits the Printrbot Jr without any problems. The benefit (as can be calculated by the very awesome RepRap Calculator) is that the Z-axis will need an even number of steps to move from one layer to the next. As an example, consider a layer height of 0.3 mm with the old 5/16″ rod: this will result in an error of +1.1217541105598867mm over 10cm, where with an M8 rod there is no such error.
  • We have not yet added a brass nut to the Z-axis because we have been unable to find one locally. An additional benefit of going for an M8 rod is that it requires no further modifications (unlike an M6, which needs a printed bit), but the M8 can still be incrementally improved, e.g. http://www.thingiverse.com/thing:64738.

At this point our main problem is with adhesion of the first layer. We have experimented with a glass plate because we want to add a heated bed. We learned a couple of lessons from that, namely:

  • Kapton tape on top of glass is not very adhesive, if it is not heated.
  • We experimented with hair-spray. Hair-spray on painter’s tape is not a good idea, it makes the tape bubble and dissolves it a bit.
  • Printing on glass with hair-spray is almost doable, but not quite convenient.
  • Adding the glass plate on top of the original wood plate adds quite a bit of height, and the plate adjustment screws cannot be tightened too much because two of them will then hit screws on the chassis, resulting in the X-axis crashing. A good solution could be a longer Z-axis stop screw.

At this point we are back to printing on painter’s tape directly on top of the original wood plate. It seems sufficiently flat for the small prints we have done until now. A heated bed is definitely a thing to do, we plan to mill a PCB on our Bungard machine, following something like http://www.thingiverse.com/thing:91403 (however note that I read double-sided PCB is recommended, because heating only one side will result in the PCB warping).

With regards to calibrating the axis for the correct number of steps the instructions at http://reprap.org/wiki/Calibration has the following quote:

The following information concerning steps/mm adjustments is outdated. It has since been agreed that steps/mm should be set to the exact calculated values since printing with non-ideal steps/mm results in an accurate test piece, but makes the dimensions on every other part even more inaccurate.

… which sort of appeals to me because it is less labor, and the correct solution can be calculated. Thus, we are now using calculated values from the very awesome RepRap Calculator: X-axis: 80 steps/mm, Y-axis: 80 steps/mm, Z-axis: 2560 steps/mm. The extruder is currently at 600 steps/mm, but this is per calibration; the PrintrBot documentation mentions a default of 569 steps/mm.

With all this effort we are now able to print various small items improving the printer:

  • Z-axis bolt holder: http://www.thingiverse.com/thing:78023. The derivation was too tight for our build, the original fits snugly.
  • 4 bed levellers: http://www.thingiverse.com/thing:90336. Nice little addition, and additionally it validated that our calibration was not totally off: one nut could be inserted by hand, the three others only needed a little “Jysk kærlighed” aka. a very small smack with a hammer.
  • New gears for the extruder: http://www.thingiverse.com/thing:26243. Our large gear already has a small crack from the original assembly, and some of the teeth on the large gear have started grinding leading to slips in movement, so we will need new ones at some point. We have printed the small gear, and will go for the large one soon.
  • An 8-bit heart, to try to explain to wifes and girlfriends what we do: http://www.thingiverse.com/thing:21795 🙂