Public Lab Research note


Oil Testing Kit Initial Electronics

by cbreuer | February 06, 2016 21:38 | 92 views | 7 comments | #12666 | 92 views | 7 comments | #12666 06 Feb 21:38

Read more: publiclab.org/n/12666


cbreuer was awarded the Basic Barnstar by warren for their work in this research note.


What I Want To Do

I'm currently working on designing the electronics and code, and eventually working on Jeff's design of the casing, for the florescence oil testing kit.

My Attempt and Results

Using Autodesk's 123D Circuits, I modeled the circuit and simulated the code running on it, which all seemed fine. The circuit currently uses a full R3 Arduino, though switching to a 3V Trinket from Adafruit should have no problems. Essentially, the circuit is just a potentiometer sending values to the arduino, where the resistance value gets scaled down to being out of 255, the max brightness value. The value is then sent to the LED, which has a hardwired switch to turn the LED on and off. The circuit/code/simulation can be found here.

Code:

int potPin= A2;  
int ledPin= 9;  
int readValue;  
int writeValue; 

  void setup() {
  pinMode(potPin, INPUT);  
  pinMode(ledPin, OUTPUT); 
  Serial.begin(9600);      
}

void loop() {
 delay(1000);
 readValue = analogRead(potPin);  
 writeValue = (255./1023.) * readValue; 
 analogWrite(ledPin, writeValue);      
}

Next Steps

I just ordered a 3V Trinket and the other parts so they should be here soon, at which point I can actually wire it up and make sure it works. One possibility for the code, which I've discussed with Jeff is the option to send the brightness value on the Trinket to Spectral Workbench, in case a use for it is found. I'll probably start looking at Jeff's design for a casing and modify it to fit the electronics.


7 Comments

So awesome, thanks Cort! I modified your code for the Trinket and put it on Codebender.com, using pin #4 (analog pin 2) for the potentiometer and pin #0 for the LED.

Been trying to connect to the Trinket but Codebender isn't connecting on my Chromebook, and 10.9+ OSX needs some serial drivers apparently. Rebooting... we'll see!

Reply to this comment...


I was able to upload the sketch, but it only changes once per second -- i was hoping for a smoother change, and I'm also not sure it's ever outputting full power, since I've seen it brighter on direct 3.3v power. So I've changed the sketch a little bit to see if the multipliers for the writeValue are off.

But I can't get it to upload again :-(

not sure, but the Trinket was in this pulsing red light state when the upload worked, and I can't seem to get it back into that state.

Reply to this comment...


OK, I apparently burned out my Trinket somehow, because I can't re-upload; but i have a 2nd one. I uploaded the latest version of the sketch (which should be at the link above) and it uploaded properly. But now I have to de-solder the LED and knob from the old one and move them to the new one. Tomorrow! Or Tuesday.

Excited -- i re-tested the full-brightness of the LED and it's mega bright. This is going to be really nice. One note, though, is that the cuvette in the current version is not up against the window, nor is the LED up against the cuvette. I think:

  • the LED should be integrated more closely into the "stack" and up against the cuvette
  • the cuvette should either be up against the window, or there should be a mask or "tunnel" so stray UV light doesn't go through the window -- just light from the sample.

Anyhow, even at low brightness it's cool to see working -- check it out, @tonyc, @matej, @liz!

Thanks again Cort, this is rad.

IMG_20160207_214753.jpg

IMG_20160207_214803.jpg

IMG_20160207_214812.jpg

Reply to this comment...


Oh hey Cort! Great to see your work again!

Reply to this comment...


Great Work! :-)

Reply to this comment...


I figured out the problem with reprogramming -- the pin I'm using for the potentiometer is also used for USB on the Trinket. Oddly, I can get it to work if the potentiometer is turned to a middle position -- not too high or low. I think we could probably avoid this by moving it to pin #2, (analog 1) -- which is not also used by USB.

Great contributions on the spec list are pointing out that we can boost the brightness with a MOSFET (IRFZ44N); I'm asking which I should order.

Reply to this comment...


Oh, reference for the pinouts on the 3.3v Trinket: https://learn.adafruit.com/introducing-trinket/pinouts

trinket_3v_microusb.jpg

Reply to this comment...


Login to comment.

Public Lab is open for anyone and will always be free. By signing up you'll join a diverse group of community researchers and tap into a lot of grassroots expertise.

Sign up