Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / A one way repeater for ham radio - will my code work? :) on: December 19, 2013, 09:06:42 pm
Hi folks

I designed a one way repeater for controlling a hf radio from a vhf radio in such a way that it can retransmit the sunday WIA news received on the VHF radio onto the HF band. This is a fairly simple concept, but I wanted to also have manual control of my radio when not rebroadcasting the WIA news (those of you unfamiliar, the WIA is the wireless institute of australia, a mob whom represent amateur (ham radio) operators in australia.

Heres what my project should do:

Interrupts on pins 2 and 3 are both looking for a low signal.
When either goes low, it closes a relay (activates the HF transmitter) and also lights the transmit LED.
If the cross band repeater switch is on, the transmitter rebroadcasts whatever is heard on the vhf radio PROVIDED its squelch is open (i.e. the signal has the correct tone and is strong enough to break through the squelch gate. The vhf radio has a handy connector that goes low or high (I forgot which way but either will be suitable for driving the opto). Once the transmission ceases and the squelch gate closes, the output from the radio stop, the optocoupler goes open and the transmit relay is de-energized, which in turn ceases transmission from the HF radio. This also lights an LED to indicate the cross band repeater is in operation.

Pin 2 is connected to a button and a switch (Press to talk and press to talk lock). When this pin is pulled low it keys the hf radio. When the button is released, it dekeys the radio.

One additional extra is the roger beep - also known as a courtesy tone (to let someone receiving my transmission know that I am finished talking and I am off the key, thus its their turn to key up and speak.). This tone will only sound if pin 10 is low (roger beep switch). it will also not sound when the cross band repeater is enabled.

when the roger beep sounds, it outputs a selectable frequency tone, with selectable duration on pin 8 before de-keying the transmitter. It also illuminates an LED to indicate the roger beep is being played.

Thats about it. its a fairly simple application, and I'll be using the ATMEGA328P IC's standalone - the arduino board is too dear and too big for these, when a prebootloaded chip will do and a handful of parts smiley

the code is in the attachment and VERY WELL documented, as such it exceeded the maximum post size of 9500 characters LOL! Will it work as intended?

Thanks for looking at my code folks smiley
2  Using Arduino / Programming Questions / Re: Arduino capacitor reformer on: November 18, 2012, 05:56:29 am
I guess it could run in a linear fashion, but I dont want it to charge any higher than maxV - doing so could turn the capacitors into little bombs.

I have made stacks of revisions to my code since I posted (not updated in post 1) and am now ready to test. Of course I'll be operating the charger, bleeder etc manually to see if the arduino does as its told. At least with subroutines (functions) I can steal them for other projects. Even the voltage readout is now a function, handy for other electronics projects that utilize an arduino, and use a voltage divider and an optocoupler.
3  Using Arduino / Programming Questions / Re: Arduino capacitor reformer on: November 18, 2012, 12:40:31 am
Ah I have rediscovered "do while" and I think I have it. Revised code in first post smiley
4  Using Arduino / Programming Questions / Arduino capacitor reformer on: November 17, 2012, 11:17:14 pm
Hi guys

I've not played with my arduino ide for a while and forgotten a lot about programming it.

I am reforming some big electrolytic capacitors. I have down pat the voltage reading, the relay control and that sort of stuff, but what I cant remember how to do is make the arduino monitor stuff and act on it, in a sequence.

The sequence will be as follows:
Initialization will set pins 2 high and pin 4 low. This disables the charger, and puts the bleed resitor online. At the same time the shorting bar is lifted. That I have sorted.

First, a quick intro to reforming caps. Caps are reformed by staircasing their charge. You start at say 25v, charge them up to 25v, let them sit on 25v, and then discharge them. You then move up to 50v, and the process repeats. During the wait, if the voltage drops significantly, you fire up the charger again to top up the charge.

The main routine should call several subroutines in order, one after the other.
1. charge the capacitors (at up to 450 volts) - there is a voltage divider calibrated to this voltage 450V = 4.50v so the arduino can read it. This is read on pin a0. During this process, the charger looks at pin a0 and compares the voltage with integer "stair" which is a voltage between 25 volts and integer maxV. When the voltage reaches (or slightly exceeds) the value of the integer stair, the charger shuts off.

2. Wait - this routine waits for a set period of time, monitoring the voltage, and topping off the charge if it drops more than 15v below the integer stair. Wait is a long time, usually 15 minutes to half an hour. During this time the voltage has to be compared and topped off constantly. This is accomplished by energising the charger briefly to bring the voltage back up.

3. Discharge.
after the wait time, pin 4 is set low (and if the charger is on, pin 2 is set high first, to disable it), and the discharge resistor is put inline thanks to the relay on pin 4. This dumps the energy in a safe manner (using a screwdriver to short out the 24000mf 450v bank is NOT a good idea!). Once the voltage hits close to 0, pin 4 goes high, disconnecting the discharge resistor

These 3 repeat 4 times, then stair is increased by 25v, and the whole process begins again.
4. Saftey.
Once the rated voltage is reached, and step 1, 2, and 3 have finished for a fourth time, a saftey system activates. This A) pulls pin 4, and pin 2 and 3 high. This completely disconnects the charger from the circuit, pulls the capacitors down to 0v with the bleed resistor, and monitors the voltage. Once in a safe range (~5v or so), pin 5 goes high, which drops the shorting contactor in place. This keeps the caps at 0v. Pin 3 goes low, which changes the connector to the 12v battery that drives the charger from the charger to a "look at the arduino stoopid!" buzzer smiley

How would I do this, bearing in mind I have already worked out

A) how to drive the LCD
B) how to read a (quite lethal to an arduino, or a human) voltage on an analog pin

My code so far:

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 10, 11, 12, 13);

float R1 = 100000.0;    // !! resistance of R1 !! (voltage divider);
float R2 = 4700.0;     // !! resistance of R2 !! (Voltage divider);
float maxV = 450; //sets the voltage rating of the caps
float stair = 25; //sets the step increment of voltage
float cycle = 4; //set the number of times for charge cycle at stairs current setting
float hold = 15; //set the hold time in minutes aka wait time until the
                 //arduino closes the dump resistor contacts.
float volts = 0;
float voltage = 0;
int chargepin = 2; //arduino pin for charger relay input;
int dischargepin = (4); //arduino pin to discharge resistor relay;
int dummybuzzer = (5); //arduino pin for the doofus buzzer;
int contactor = (3); //arduino pin for the shorting contactor;
int state = 0;
int timed = 0; // 100msec interval timer
int time = 0; // seconds for wait timer

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("Cap Former V1.0");


void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  volts = analogRead(voltage);
  volts = (volts * 5) / 1024;
  volts = volts / (R2/(R1+R2))*10;
  lcd.print("State ");
  if (state = 1) lcd.print("Charging");
  if (state = 2) lcd.print("Holding");
  if (state = 3) lcd.print("Discharging");
  if (state = 4) lcd.print("Finished!");
  if (state = 1) int charge ();
  if (state = 2) int wait (hold);
  if (state = 3) int discharge ();
  if (state = 4) int saftey ();
  delay (100);

int charge (){
volts = analogRead(voltage);
  volts = (volts * 5) / 1024;
  volts = volts / (R2/(R1+R2))*10;
  lcd.print(" V");
 while (volts<stair);

int wait (){;
timed = 0;
time = 0;
  volts = analogRead(voltage);
  volts = (volts * 5) / 1024;
  volts = volts / (R2/(R1+R2))*10;
  lcd.print(" V");
  if (volts < stair - 15) digitalWrite(chargepin,LOW);
  if (volts > stair) digitalWrite(chargepin,HIGH);
  delay (100);
 if (time = 1000) timed=timed + 1;
 if (time = 1000) time =0;
while (timed < hold / 60);

int discharge (){
  volts = analogRead(voltage);
  volts = (volts * 5) / 1024;
  volts = volts / (R2/(R1+R2))*10;
  lcd.print(" V");
  delay (100);
if (volts < 5) digitalWrite(dischargepin,HIGH);
while (volts < 5);

I am totally lost with the rest of it - subroutines would be a bright idea, and just step through main onces each finishes (charge, hold, discharge, saftey. Infact, when saftey is called, it can put the arduino to idle mode provided the relay board pins stay in their current state.)

Really all i need to know is how to follow the steps in sequence, waiting for each one to complete, before starting the next, and finishing at the end with an idle state. Kind of like a steeple chase horse race - the horses start at the starting gate, go around the track, jumping the barrier things, and ending up at the finish line. The jumps could be compared to our steps, the starting line void setup, and the finish line step 4, which is only called once the program has run its course.
5  Using Arduino / Displays / Re: 4D Labs μLCD-μLED-μVGA Serial LCD Library on: February 14, 2012, 08:07:30 pm
Thanks Avenue - should get my screen in a day or 2. 0023 it is smiley
6  Using Arduino / Displays / Re: 4D Labs μLCD-μLED-μVGA Serial LCD Library on: February 12, 2012, 06:51:12 pm
Hi Avenue - which IDE has the latest version of your driver on github - I assume its 0023, and not 1.0

Need to settle on an IDE to use for my project. Just ordered my uLCD32 smiley
7  Using Arduino / Displays / Re: 4D Labs μLCD-μLED-μVGA Serial LCD Library on: February 12, 2012, 07:45:14 am
Avenue this library looks awesome - so much so that I might install the 0.22 IDE and buy one of these screens for my laser controller.

It has everything I want - buttons, menus, dialogues etc.

Looks like I have some work ahead of me smiley

Thanks for working on this!
8  Using Arduino / Project Guidance / Re: Ion laser controlled by Arduino on: February 11, 2012, 03:01:11 pm
hey rob - cheers.

Between this and my last post I got the power output voltage divider working and coded. It now measures correctly (0-15V) multiplied by 10 (for 10mw/V).

Next is the current divider - 0-6.5v at 2A/V
9  Using Arduino / Project Guidance / Re: Ion laser controlled by Arduino on: February 11, 2012, 01:25:58 pm
For nothing more than to experiment with lasers.

I'm building this controller as a nice addon for my laser. I'm a member of Laser Pointer Forums and PhotonLexicon, both forums deal with lasers. The former is more pen laser and collecting lasers oriented, the latter into amateur/professional laser show production and experimentation with laser projectors orientated. Since I am into both (laser collecting and show creation), both forums suit me. smiley

I am not interested in making money from the project, and once the code is complete I'll post the code to both forums, and offer preprogrammed and wired setups for the cost of parts and postage, along with a beer, for those who are turn key operators (dont know the hot end of a soldering iron from the cold; yet can plug in a gadget and configure it).

I am also a bit of an electronics nut. Since my post I have created the voltage dividers, and am now going to connect them to the arduino to work out what happens (by displaying the output of an analogue pin as I increase the voltage from 0-15 (at the divider i'll see 0-4.75 v, so dont worry, I'm not going to pop my arduino!) smiley

This is a / 3 divider but due to component tolerances, I'll need to put an offset in. By working out what the arduino's analogue pin spits out per volt, i can go on to create a simple forumla to work out the power output of the laser from the original designs 10mw/V. Since the divider is / 3 the power will be 10mw/333mv. However the arduino doesnt give a nice "You've got 333mv", it gives a number from 0 to 1023, so a bit of code to translate that, and I have my laser power subroutine.

P.S. loving my new soldering station. Heats in 60 seconds, interchangable tips, 250-450C, sleeps if you dont use it... how i survived with a dick smith or radio shack cheapie I dont know smiley
10  Using Arduino / Project Guidance / Ion laser controlled by Arduino on: February 11, 2012, 09:44:58 am
Hi folks. New to Arduino and this forum! Not looking to be spoon fed though, Already got my arduino driving a 16x2 LCD and a quad relay bank. I'm pretty chuffed I got this far without asking for any assistance just by reading and playing.

The plans for my arduinos are:
1. Control an ion laser
2. Control a BPSK31 beacon transmitter
3. Control some lights over DMX

OF course these projects are not all to be covered in this topic. This topic is about the ion laser.

I'm planning to use a duemilanove to control this laser using the following peripherals:
a 4x20 LCD screen
a series of press buttons (resistor network)
a stepper motor driving a 25t trimpot (poor mans digipot)
a set of relays for sequencing
a pair of voltage dividers to sense tube power and tube current.

So far I have got my Arduino to run the screen and chase the relays. This was self learning, reading and playing with code to make the relays turn on and off for one seconds in sequence, and display the currently powered relay on the screen.

Heres a You tube clip of the result:

So far so good. My first arduino program after "hello world" and "blink a led".

The project I am constructing with the arduino needs to do the following:

1. Read the eeprom and put these values aside for limits, and configuration data
2. Display a menu
3. Listen for press buttons
4. Monitor the voltage dividers
5. Sequence the relays when commanded to start the laser
6. Rotate the stepper when commanded to increase or decrease the lasers power.

Point 1 is fairly simple - read each eeprom value and store it in a variable for later use in the program (e.g. maximum tube current, maintenance burn timer value, head hours)
Point 2 is a pain. The menu has the following structure:

+Main Menu
   + Normal Run
   + Maintenance Burn
   + Settings
   + Test Mode

Function 1 starts the laser, and is a normal run, allowing the user to adjust power, set ilde/run mode, Light/Current mode, etc

Function 2 starts the laser, sets the power to midrange, and counts down the burn time. Once it reaches 5 minutes to go, it idles the lasers, then shuts it off. Argon lasers function best when they are run once a month. This menu item automates this.

Function 3 allows the user to enter the particulars of their lasers such as maximum safe tube current, how long they want the default maint burn time to be, what the hour meter on the head reads (it can be hard to get at, so being able to see it on the controller makes life easy), and other configuration parameters.

Function 4 allows the operator to test the arduino without a laser connected - cycling the relays, checking the voltage dividers etc.

Point 3 is easy. Use an analoge pin and buttons on a voltage divider string to pass button presses to the controller

Point 4 is also fairly easy but I suck at maths. A voltage divider converts the analogue 15v scale of the lasers feedback pins (mw/V and A/V) to 0-5v so we dont blow the Arduino. From here the scale is then mathematically converted into a more user friendly value (e.g. 35mw, 6A)

Point 5 is simply a sequence of events handled by relays during each run.

Relay 1 is the fan. This turns on at any time the laser is called into operation. Without it the tube will melt down. This relays simply allows the Arduino to turn on and off the fan when needed (on during run and cooldown, off when the unit is in laser off standby mode)

Relay 2 is the enable relay. This relay only energizes when 3 conditions are met initally, and one is met during run. Initally the Key must be in the on position, the idle/run switch must be in idle, and the E-Stop is open. During run the program monitors the key or E-Stop and kills the laser if the E-Stop closes, or the key opens.

Relay 3 is the Idle/Run relay. When open the laser idles at lowest power. When closed, the laser runs at whatever power is dictated by the voltage divider set at the stepper controlled trimpot, depending on wether its output is connected to the light or current input of the light/current mode relay

Relay 4 is the light/current mode relay. Ion lasers are run in two modes - Light feedback mode, where the tube produces a constant power output, or Current, where the tube is set to a current level, and the light output is what it generates when recieving that current. So if the tube puts out 10mw/A, at 6A the tube will be doing approximately 60 mw.

Point 6 is easy. Its a pot basically, with a stepper motor mentality. Rotate the stepper one way to increase, the other to decrease. By using a high rpm to get close to our target value, and a low rpm to lock on, the stepper could be quite accurate.


Normal run:
In normal run mode, once the start command is called, the controller would do the following:

1. Check all interlocks are closed (E-Stop, Key, Idle/run switch, case)
2. Call the preheat subroutine
3. Start the laser at the lowest power
4. Listen for button presses and adjust the stepper accordingly or stop the laser
5. monitor the feedback loop and math and display the output on the screen.
6. Call the cool down subroutine when shutdown is requested

Maintenance burn mode:
1. Check interlocks
2. Call the preheat subroutine
3. Start the laser at the lowest power. Wait 5 minutes
4. Ramp the power up to half power. Count down to the last 5 minutes of the timer
5. Ramp back down to idle power
6. Call the cooldown subroutine

This simply collects data from the user. This includes Tube maximum allowed current, Head current hours, M/Burn timer default, Voltage divider offset, stepper data. When each value is saved, the Arduino stuffs the result into its corresponding EEPROM address for recovery after a power cycle/reset. If all the blocks used by the program read 255, lock the user into the config screen until the values are filled out. This prevents a laser trying to do a current it was never meant (and nor the power supply is capable of supplying) to do. (e.g. 25A LOL)

Test Mode:
This simply allows the user to test all functions of the controller to calibrate it and make sure everything is working before connecting it to their laser.

*phew* thats the menu and tui outline done.

The preheat subroutine simply enables the fan, and closes the enable relay. This provides power to the ion laser tubes filament. The filament has to be allowed to get hot (and the filter capacitors in the PSU to precharge) before firing. This takes about 45 seconds. During this routine the screen will display:


(the # represent a solid block. It advances along the screen until the preheat cycle completes).

Cooldown is the opposite of preheat; it puts the laser into idle mode, runs it here for 5 minutes, shuts off the enable relay (de-energizing the tube and filament) and then runs the fan for an additional 5 minutes. Its screen would look like:

*Idle  *Fan  08:44
Danger! Beam ON!

and when the idle mode disengages:
 Idle  *Fan 3:12
LASER is safe.
Typical run screens:

Light mode in run mode
Normal Mode: Run
Light mode: 35mw
<--------+---------> <--- this is a power meter
Current: 7.1A

Light mode in idle:
Normal Mode: Idle
Light mode: 4mw
Current: 3.7A

Normal Run Screen (current mode)
Normal Mode: Run
Current Mode: 9.7A
Power out: 109mW

Settings Screen (tube current used as example)
Settings: Max Tube I
Use < and > to adjust
Max current: 9.3A
Start=Save. Stop=Discard

Settings Menu
> Tube Max I      <
   Head Hours
   Burn Timer

Maintenance Burn Screen:
Maintenance Mode: 15:29
Power Out: 45mw
Current: 7.25A
Press stop to cancel.

Main Menu Screen
Press <> to Select
Start to choose
>Normal Run      <
 Maintenance Burn

An error Screen:
Key switch.
Laser Disabled
Turn Key to resume

What I am looking for assistance with:

1. An easily edited menu system for a 4x20 screen
2. ways of looking for button presses without halting the program
3. A little help with math (I dont expect you to do the math, but to help me work out how to make the Arduino interpret a value on its analogue pin to a real reference e.g. seeing 123 on the analoge pin as 10mw, would tell me that 236 on that same pin would indicate 20mw of power.)

Funny thing is, I dont even have the laser yet.

Outputs from laser PSU:
Measure mw, on two pins you get 1V per 10mw (e.g. 15V=150mw)
Measure Current, on two pins you get 2V per A (e.g. 3V=6A)

Insights, thoughts and comments welcome smiley
Pages: [1]