Tuesday, June 21, 2016

Semi-Automatic Data Collection

     Using an Arduino and a speaker, I have made a way to semi-automate the data collection process. What it does is emit a tone through a speaker then waits 35 seconds, this gives the counter enough time to collect data. The only thing the user has to do is hit the green button in the STX program to begin counting every time they hear a tone. They also have to change the preferences to 3 runs and the preset time to 10 seconds at the beginning. An LED can be also be used for the hearing impaired, and it will blink when the it is ready for the counting to start.
     This was the best solution I could think of. I could not find a way to fully automate it. There does not seem to be a way for the arduino software to communicate with the STX software. However finding a way to fully automate the process would be interesting.  

     I will leave the code in the comments, it goes into further detail of how to set up the circuit. I will also include a code that uses a button to move the motor and a variable resistor to change direction.  
     

Friday, June 17, 2016

First Experiment- Bragg Method

We ran our first experiment with the machine. We used the Bragg method to calculate the wavelength of the waves being defracted by a NaCl crystal.

We mounted a NaCl crystal on the crystal post of the machine, set the machine to 30 kV and .05 Amps then used the GM tube to collect the counts. We took the measurements for 10 seconds and did three trials for each degree. We moved the GM tube by one degree starting at 20° and ending at 90°.






Our data resembles the data provided in the manual but heights of the peak are smaller in our data. This could be because the beam is not running at full strength due to age or another problem we have not identified yet.

To measure the wavelength we used Bragg's law. Bragg's law states nλ=2dsinθ, where n is an integer, λ is wavelength of the x ray, d is the distance between atoms in the crystal and θ is the angle. For this experiment n=1. The distance for a NaCl crystal is .282 nm. The two peaks are at 31° and 58°.The wavelengths at the two peaks are .29 nm and .49 nm respectively. Both of these wavelengths are consistent for x-rays.




     

Friday, June 10, 2016

Moving the Motor

To control the stepper motor I am using an arduino uno, an adafruit motor shield and a potentiometer. The motor has 9 pins, I connected 3 and 5 to M4 port on the motor shield and pin 4 to the M3 port, I am not sure why this configuration works but it does. I then have the middle wire of the potentiometer connected to A0 and the other wires connected to ground and 5V. The motor shield is connected to a protoboard which is supplying it with about 8V.



I wrote two different codes to control the motor, one uses if statements and the other switch/case statements. They both do the same thing but a little differently. Both codes can be used interchangeably. I will put both codes in the comments section. The library AFMotor.h can be found on the adafruit website here as well as examples of the library in use. 

The next step is to find a way to tell the motor to move to a certain angle and then do a sweep between angles.  

Tuesday, June 7, 2016

Safety Protocol


1. Verify that a sign has been posted at eye level on the door(s) to the lab room warning that x-rays can be produced in this location.

2. Check that the power strip is turned off at your lab station. Check that the Tel-X-Ometer and the scalar meter power supply are plugged into the power strip.

3. Physically inspect the plastic scatter shield cover. Examine the entire shield to make sure that no cracks or chips are present. Make sure that the aluminum/lead backstop is securely in place.

4. Gently check that the cover hinges slide freely in both directions. When you are using the x-rays later in this lab, you can turn them off simply by sliding the cover to one side. This will break the interlock and turn off the x-rays. When the carriage arm is rotated to one side, then always slide the cover to the same side as the carriage arm.

5. Check that the lead-glass dome containing the x-ray tube is entirely free of chips or cracks. The x-rays will be emitted through the port. Verify that the port is firmly attached to the dome.

6. Verify that both the Indicator Lamp next to the lead-glass dome and the red push-button on the Control Panel are legibly labeled “X-RAYS ON”.

7. In addition, establish that underneath the red push-button on the Control Panel there is a clearly legible and visible label bearing the statement “CAUTION: X-RAYS PRODUCED WHEN ENERGIZED”.

8. There should be a GM tube mounted in the carriage arm of the Tel-X-Ometer. This GM tube should be connected to the scalar meter through a BNC connection.

9. Obtain a Tel-X-Ometer key from the lab instructor. Insert the key into the switch to free the controls. Check that the key can only be removed when the control is in the off position.

10. Turn on the power strip. Turn the timer knob to ~30 and turn the key to the on position. Verify that the Power On Indicator Lamp (white) is illuminated and that the x-ray tube filament is illuminated at the same time. The Scaling Ratemeter may start beeping on occasion - this is perfectly normal.

11.  For additional protection, the user can set up a lead wall around the x-ray machine using lead blocks, and/or wear a lead apron. 

* Any person/people around the machine should wear an x-ray badge to detect how much radiation they are receiving. 


www.compadre.org/advlabs/wiki/File%3A2584

Monday, June 6, 2016

Turning On

To turn on the Tel-x-ometer, plug it into an outlet.  On the left side of the face you will notice there is a switch that can be set to 20kV or 30kV, turn the switch up so it is set to 30kV.  Make sure that the GM tube is pointing towards the x-ray tube and close the lid of the Tel-x-ometer.  When closed properly, the lid will allow the x-rays to be produced and when the lid is displaced the x-rays will stop being produced.  After ensuring the lid is on properly, turn the key and the power will be on (the white light should light up).  The last step is to push the red button on the side of the Tel-x-ometer and this will allow the x-rays to begin producing (the red light should light up).  For best results, it is recommended to let the filament light up for around 5 minutes (it is normal if there is condensation on the lid while heating up) and then to turn on the x-rays.

The counter should be plugged into a power source.  A BNC cable should be connecting the GM Tube to the counter.  The voltage from the counter to the GM Tube should be around 360V and the current, using an ammeter, should read 0.50 microamps.

Arduino Voltage Divider

The amount of X-rays the X-ray machine can produce depends on the current which can be controlled by a potentiometer on the front of the machine. It will be helpful to how much current the machine is using so an experiment can be reproduced. We want to use a arduino for this but the machine runs at 30k volts which is way too much for the arduino. So I used a voltage divider.

A voltage divider drops voltage to a safe amount. It uses a input voltage and two resistors in series. More information about voltage dividers can be found here I got the arduino code to use use a voltage divider from this website. The code measures from the analog pin to get the voltage. There is some calibration that needs to be done which is explained on the same website. This code measures the voltage out, I want to measure the voltage in so I used the equation, V_out=V_in*(R2/(R1+R2)), and solved for V_in. Then used Ohm's law to solve for current, I=V/(R1+R2).

I tested it out using a 9V battery, 1000 and  330 ohm resistors and the measurement was only off about about .1V. This could be because of the resolution of the analog pin. To set it up but the resistors in series with R1 connected to the positive end of the battery followed by R2 then to the battery's ground. Connect pin A3 to the end of R1 and the start of R2. and connect the Arduino's ground to the battery's ground. Upload the code and look at the serial monitor (ctrl+shift+m).
Serial Monitor Output

Arduino and Breadboard




Here is the code I used-
// number of analog samples to take per reading
#define NUM_SAMPLES 20

int sum = 0;                    // sum of samples taken
unsigned char sample_count = 0; // current sample number
float voltageIn = 0.0;   // calculated voltage
float current = 0.0;
float voltageOut= 0.0;
float Ra=1000.0; // Resistor 1
float Rb=330.0; // Resistor 2

void setup()
{
    Serial.begin(9600);
}

void loop()
{
    // take a number of analog samples and add them up
    while (sample_count < NUM_SAMPLES) {
        sum += analogRead(A2);
        sample_count++;
        delay(10);
    }
    voltageOut = ((float)sum / (float)NUM_SAMPLES)*5.08 / 1024.0;
    voltageIn = ((Ra+Rb)/Rb)*voltageOut;

    current= voltageIn/(Ra+Rb);
    
    Serial.print(voltageIn); 
    Serial.print(" V"); 
    Serial.print("\t");
    Serial.print(current,4);
    Serial.println( " Amps ");
    sample_count = 0;
    sum = 0;
}


When using the X-ray machine the input voltage is 30k so we will use 470k and 39 ohm resistors. This combination drops the voltage to a safe 2.43V. I have yet to test it with the machine but my only worry is the resistors not being able to withstand the wattage and heating up, smoking and failing.            

Wednesday, May 25, 2016

Relay Software

This post will list the python commands needed to control the relay board as well as how to run the commands from the command line.


Every script should have these three lines:
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(x,GPIO.OUT) #x is the pin number, this tells the raspberry pi that                                                    the pin is an output

The first line imports the library, the second line tells the program how the pins are numbered and the third line tells the program that the pin is an output.

The next two lines turn the relay on and off:
GPIO.output(x,GPIO.HIGH) # this turns the relay light on
GPIO.output(x,GPIO.LOW)  # this turns the relay light off

Try and except, while loops and/or for loops can be used to with these commands to make the relay do different things, see this video's description for example codes. For multiple relays it is helpful to put the pin numbers in a list. This makes running for loops over multiple pins easier.  

To run the script from the command line type, python filename.py


To control the board from the command line without a script start by typing python, then entering the three lines above (import, setmode, setup), then GPIO.output(x,GPIO.HIGH) and GPIO.output(x,GPIO.LOW). Use the up arrow to switch between the two. To quit python type quit().