Sciencemadness Discussion Board
Not logged in [Login ]
Go To Bottom

Printable Version  
 Pages:  1  ..  3    5    7  ..  9
Author: Subject: Building a polarimeter
smaerd
International Hazard
*****




Posts: 1262
Registered: 23-1-2010
Member Is Offline

Mood: hmm...

[*] posted on 22-5-2014 at 12:51


Be careful with the math hahaa. I have read in many places it is nearly impossible to calculate the actual capacitance needed to stabilize transimpedance op-amps like this. A lot of it boils down to trial and error, redesign, etc.

I also should mention there is a capacitance from the audio jack across the diode as well. We'll see.




View user's profile View All Posts By User
aga
Forum Drunkard
*****




Posts: 7030
Registered: 25-3-2014
Member Is Offline


[*] posted on 22-5-2014 at 12:58


it's not the capacitance : it's the sheer Gain you're expecting from that op-amp

If i were not drunk, i'd search the net for op-amp examples and calculators.
Then i'd look up the optical device tech data.

Then i'd see if my op-amp gain Had to be in the millions, and if so, there's no way it would be stable, ever.

That's why multi-stage amplifiers exist.

Amplify a bit, pass it on to the next stage.

No amount of capacitor fiddling will do.

[Edited on 22-5-2014 by aga]




View user's profile View All Posts By User
aga
Forum Drunkard
*****




Posts: 7030
Registered: 25-3-2014
Member Is Offline


[*] posted on 22-5-2014 at 13:16


To be totally fair, ths is like me expecting 100ml Pure Sulpuric Acid from a 40ml beaker containing wood ash and water.

Your device Will work, but that circuit will not.

Give me a day or two and i will look up the tech specs on your detector and op-amp and see if i can find a solution.

Feel free to Nag if i do not deliver on time.




View user's profile View All Posts By User
smaerd
International Hazard
*****




Posts: 1262
Registered: 23-1-2010
Member Is Offline

Mood: hmm...

[*] posted on 22-5-2014 at 14:30


Thanks Aga. I was kind of thinking the same thing, but so many of these example circuits use 10Mohm, and even gigaohms. I was looking at that and scratching my head after I had read up on signal noise. I believe the LTC 1050 has a max gain of 20db also. So I am sure I have been wayyyyy over-loading it. This would also explain the clean signal with the extra capacitance.

I think I will try a transimpedance(current->voltage) which leads to a classic non-inverting voltage amplifier. I believe with 440kOhm resistance I was seeing 0-0.125V signals. So a R1/R2 = 40ish (or 20ish to be safe) should be fine. Again that's two stages with pretty big gain and most people say that to put the noisiest/largest gain stage as the first one. We'll see. I'll attempt it using two LTC1050's. It just makes the most sense right now.

[Edited on 22-5-2014 by smaerd]

Update- Ran my first trial with a dual stage amplification. Not bad. I mean very noisey but this seems like it will be easier to hone in on. As it is noise, not wild oscillation(okay some oscillation but it looks like there are two wave-forms not an infinite sweep).

Think the next step is actual shielding(not laying down foil), and transferring to prototype board after a few more simple tests. Then fine tuning capacitors/resistors as best I can. Also, Aga I took your advice. Drank a few beers for science. Well, the first one was to shield the motor :P, the second was well just incase I cut the can wrong, etc.

two stage amplification first attempt.png - 27kB

[Edited on 23-5-2014 by smaerd]

[Edited on 23-5-2014 by smaerd]




View user's profile View All Posts By User
aga
Forum Drunkard
*****




Posts: 7030
Registered: 25-3-2014
Member Is Offline


[*] posted on 23-5-2014 at 07:38


I just started looking at th circuit and the BPW21 specs.

It's wired the wrong way round in theose circuits you posted.

Seems it's light sensitivity alters it's reverse bias current, not foward bias.

Also seems odd to be tying the + of the op amp to -5v, but i guess that's typo.

A quick google for 'BPW21 circuit' comes up with a bunch of images of circuits to do wxactly what you want.

[Edited on 23-5-2014 by aga]




View user's profile View All Posts By User
smaerd
International Hazard
*****




Posts: 1262
Registered: 23-1-2010
Member Is Offline

Mood: hmm...

[*] posted on 23-5-2014 at 07:40


Are you sure? I just started getting great data.

The gain is nearly perfect(~0-~2.0V), the oscillations are gone. Just some stray noise. Need to fine tune this and see where this can be coming from. Motor is shielded. Should shield the audio jack plug next to see if that will improve anything. I don't know if I need an RF choke or not. Not sure if the analog pins have a common ground with the digital on the leonardo, I'll have to check to be sure. I'm thinking that a teeny tiny bit more tuning with capacitance and this thing can go onto some perf board!

so close dual stage.png - 23kB

[Edited on 23-5-2014 by smaerd]

[Edited on 23-5-2014 by smaerd]

[Edited on 23-5-2014 by smaerd]




View user's profile View All Posts By User
aga
Forum Drunkard
*****




Posts: 7030
Registered: 25-3-2014
Member Is Offline


[*] posted on 23-5-2014 at 07:44


'Course i'm not sure.

Hey ! if it's working, it's working !





View user's profile View All Posts By User
smaerd
International Hazard
*****




Posts: 1262
Registered: 23-1-2010
Member Is Offline

Mood: hmm...

[*] posted on 23-5-2014 at 07:59


Should I try to put some capacitors between my stages on the supply rails? Maybe it's voltage ripple from the varying two stages?



View user's profile View All Posts By User
aga
Forum Drunkard
*****




Posts: 7030
Registered: 25-3-2014
Member Is Offline


[*] posted on 23-5-2014 at 08:09


Smoothing the supply as close to the devices as possible is aways a good idea.

As there 's a ADC converter somehere, you'll probably be getting some variation in how accurate that is, which will introduce some more noise in the data..

[Edited on 23-5-2014 by aga]




View user's profile View All Posts By User
smaerd
International Hazard
*****




Posts: 1262
Registered: 23-1-2010
Member Is Offline

Mood: hmm...

[*] posted on 23-5-2014 at 09:23


Forgot all about the ADC... Well I've shielded damn near everything I can think of. I need to take this to perf-board. Alot of this could be induced by stray capacitance of the ridiculous jumper wires I am using. Or capacitance of the spinning audio-jack(worst case scenario) I am using this type,
.

Honestly every connection has 2-3 inches more wire then is necessary. Also there is the capacitance of the bread-board itself, and resistor prongs. It's also a lot harder to shield a bread-board(can't wrap it in foil without risking shorts). The PWM motor driver bread-board running with 12V is maybe 3 inches away from the detector board as well. Tried shielding it but it's a tangly mess. Need to put that on perf board as well and shield it. Once it's on perf, I should be able to tune it. I'll wire wrap the capacitors until I get where I need to be.

Well one thing I did realize with this project is, the mechanics/code and circuit could be used to build a UV or at least a VIS spectrophotometer(~200$ spectrophotometer that isn't a black box). Rather then rotate a polarizing element, rotate a grating element. So once I figure this out that may be an interesting follow up project. Or maybe someone else will take the lead using the same kind of idea. I'll definitely be making it all public domain once finished.

[Edited on 23-5-2014 by smaerd]




View user's profile View All Posts By User
unionised
International Hazard
*****




Posts: 5109
Registered: 1-11-2003
Location: UK
Member Is Offline

Mood: No Mood

[*] posted on 23-5-2014 at 09:42


This is probably a stupid question, but can you easily see the light that gets through the cell?
If so then measuring it should be simple enough.
View user's profile View All Posts By User
smaerd
International Hazard
*****




Posts: 1262
Registered: 23-1-2010
Member Is Offline

Mood: hmm...

[*] posted on 23-5-2014 at 09:52


It's not a stupid question but I am not sure what you mean if I see the light? Yes the light is visible on the detector to me and to the detector, but I try not too peak while the thing is running. I have not tested it with a cell yet. I am currently working on an algorithm to position the analyzing polarizer to a minimum. Then as soon as that is done, I will be able too implement the pre-written measure command to take a measurement(series of measurements), and observe the data. Which the soft-ware will then give the appropriate information useful for chemical analysis. So essentially once this noise is gone. An hour of programming and tidying up and this should be a completed project. Wellll, I still need to buy a cell and build a little mount for it, for testing but that will happen when the time comes... Or I'll come up with plans to build one for an affordable price...

Also long over-due are the instrument photographs. Had to borrow someone elses camera as mine stopped working. As you can see the laser circuit is currently disconnected from the arduino board for now and running off two triple AA's. Kind of a nuissance but I am trying to eliminate all the variables I can while working out this portion of the circuit.

Edit - Please don't judge too harshly on the choice of beer. It was what was in the fridge :P

one.JPG - 133kB two.JPG - 146kB three.JPG - 140kB four.JPG - 85kB

[Edited on 23-5-2014 by smaerd]

[Edited on 23-5-2014 by smaerd]




View user's profile View All Posts By User
aga
Forum Drunkard
*****




Posts: 7030
Registered: 25-3-2014
Member Is Offline


[*] posted on 23-5-2014 at 13:37


Cool !

Yes, at the Gain you want, those wires are not Jumpers, they're Antennae !

The circuit is fairly simple, and you'll save yourself a load of bother by using some veroboard from now on.

I got some polarised film today, so i'll have a crack at a back-scatter type of polarimeter soon.

[Edited on 23-5-2014 by aga]




View user's profile View All Posts By User
smaerd
International Hazard
*****




Posts: 1262
Registered: 23-1-2010
Member Is Offline

Mood: hmm...

[*] posted on 23-5-2014 at 14:12


Awesome! Never heard of a back scatter polarimeter. I'd love to hear about your progress/design. Edit - Oh wow! http://pubs.acs.org/doi/abs/10.1021/ac951169b

Polarimetry in Capillary Dimensions
Darryl J. Bornhop * and Joseph Hankins
Anal. Chem., 1996, 68 (10), pp 1677–1684

Yea I just read an article by bob pease "What is all this common ground noise anyways?". Was pretty enlightening. I also remember from my physics course about what Mr. Faraday and Mr. Maxwell said pertaining to loops of wire in the presence of changing magnetic fields :P. I also realized how bread-boards are almost perfect for creating those loops... I'll have to read up on good lay-outs to avoid this when I transfer the thing to perf. board. Also the effect of the photodiode and the circuit desperately wanting to pull current from all over has been a bit mind-blowing to me. I'd love to see the thermodynamic or E&M theory explaining this more fully.

[Edited on 23-5-2014 by smaerd]




View user's profile View All Posts By User
aga
Forum Drunkard
*****




Posts: 7030
Registered: 25-3-2014
Member Is Offline


[*] posted on 23-5-2014 at 23:42


Te idea i had was simply to put a polarised filter in front of the laser, and a rotating polarised filter in front of the detector.

This is a bit of an addition to the Ramen thing i've been working on (and getting nowhere fast).

Here's an aciiart representation of what i'm trying to do :-

SAMPLE
/ \
(L E N S)
|
\ ------<------ Fixed Pol. Filter ----- LASER
mirror

(L E N S)
\ /
Rotating Pol Filter
\ /
Detector

I used to have a great camera and loads of software tools to manipulate images.
Now i have Windows 8, and so have absolutely nothing useful anymore.

The Mirror is a shard of broken mirror, as small as it can be to deflect Only the laser beam, glued to some stiff wire.
The idea is to try to avoid as much glass as possible (i.e. no splitter) and also reduce the amount of Rayleigh lght directly in the beam.

[Edited on 24-5-2014 by aga]




View user's profile View All Posts By User
smaerd
International Hazard
*****




Posts: 1262
Registered: 23-1-2010
Member Is Offline

Mood: hmm...

[*] posted on 24-5-2014 at 09:59


Very interesting. I assume a mirror will be behind the sample? I'm a little confused by the optical diagram but hell it's ASCII hahaha. Think I get the jist. Well I fine tuned my code and found the actual number of pulses per revolution. Made a mathematical error in my early theoretical calculations that unfortunately stuck with me until now.

Anyways the harmonic regression is now 'dead-on'. So I can move forward a bit. By tonight I will hopefully have the majority of the soft-ware written. The analysis for the measurement of the sample will likely require a fourrier transform which is something I kind of over-looked until now that it's almost on the to do list.

fine tuned algorithm.png - 27kB

[Edited on 24-5-2014 by smaerd]




View user's profile View All Posts By User
aga
Forum Drunkard
*****




Posts: 7030
Registered: 25-3-2014
Member Is Offline


[*] posted on 24-5-2014 at 11:44


Brilliant !

It is exciting to see you making progress so fast

FFT algorithms are out there on the net by the dozen.
FFt = Fast Fourier Transform. No point using the slow one ...

Here's one in C++ (duno what language you're writing in) :-
http://www.drdobbs.com/cpp/a-simple-and-efficient-fft-implem...

One thing about FFT is that the sample rate for a given resolution via an FFT needs to be the 'Nyquist Number' above the resolution required.

It's 2.
Work out your sample rate, divide by two and that's your resolution.

Sorry about the Ascii art, which unfortunately lost the spaces i put in.
No, there's no mirror.
Hopefully the refected or re-emitted light will also show some polarisation shift.
i can't immediately see if passing light through a substance, relfect it, then pass it through Again would cancel the polarisation shift, or double it.
Will see if i get time to try it tomorrow.

[Edited on 24-5-2014 by aga]




View user's profile View All Posts By User
smaerd
International Hazard
*****




Posts: 1262
Registered: 23-1-2010
Member Is Offline

Mood: hmm...

[*] posted on 24-5-2014 at 19:08


Ooo that looks highly adaptable aga. I am using JAVA simply because it's a quick development language. Not quick performance-wise, but I've had no issues yet.

Well happy to update. I worked out the orienting algorithm, and the measuring algorithm(which was cake). Now I can officially say, noise aside, I have constructed an automatic polarimeter!

To do list:
- Obtain a sample cell
- To transfer circuits to perf board and shield (should handle the noise)
- Fine tune some of the algorithms once I have non-noise results
- Have the soft-ware to plot the results(already have it set up have just been lazy), and find maxima's.
- Test with some known compounds and get some real results.

It's been a long journey! I would apologize for spamming the crap out of this thread with noisey data and my thoughts but, I'm not exactly sorry.

The following image is a 180* rotation of the analyzer to find/interpolate the nearest minimum intensity value on the analyzer to rotate too.
first measurement orientation algorithm.png - 20kB

The following image is what happens once the minimum is found and the measurement button is pressed. The analyzer rotates generally about 90* away from the darkest point(with the sample in instrument) to obtain a 'semiconstant' angular velocity. Once it hits the minimum the data collection begins. Once it goes 360.0* from the minimum the data collection ceases. With nothing in the sample compartment, clearly two peaks are the result. Notice they are ~ equal in height now that the laser is aligned.
first measurement of nothing.png - 18kB

Interestingly the noise on the second peak is more severe. I believe this may be attributed to the antennae effect. The longer the gain circuit operates, the more it wants to induct/pull from the fields in the air. We'll see.

Start(orienting) to finish(measurement) it takes around 1 minute. It might be fun to write some kinetic experiment handling in the soft-ware. A fun test would be to do the classic mutorotation of glucose? Or maybe it's sucrose I forget, my brain is fried. Then compare results. Would be really nice not having to touch a thing either.

Drinking a beer to celebrate. Well actually to tone down the ridiculous concentration of caffiene and theobromine coarsing through my body. Irregardless, very happy!

@Aga - Thanks for following this with me. I'd love to see your back-scatter polarimeter set up. It's an interesting concept. I will have to think about whether the polarization will increase or not after reflection. Probably be more fun to experiment with it though. Never know what you might find.

[Edited on 25-5-2014 by smaerd]

[Edited on 25-5-2014 by smaerd]




View user's profile View All Posts By User
smaerd
International Hazard
*****




Posts: 1262
Registered: 23-1-2010
Member Is Offline

Mood: hmm...

[*] posted on 29-5-2014 at 14:10


A little upset. Went from bread board to perfboard in hopes of getting a cleaner signal. Instead I somehow have an incredibly awful one. I'm not sure what is going wrong just yet. A little worried I may have somehow fried one of my op-amps while soldering. Might save troubleshooting until tomarrow as this has been a real disappointment and I've triple checked the circuit.

rawrrr.png - 40kB

Edit- I cleaned up the signal a little bit, but there is no or very small amplification. No longer are they clean sinuisoids, and the noise is just as bad if not worse than before. Ughhh, might of been better on bread-board.


Bought some DIP 8 sockets. I definitely fried ANOTHER op-amp hahahaha, this time by soldering. Ordered some different ones that should be good performance-wise. So it will be back to bread-boarding then protoboarding in 4 or so days... Soon as this circuit is done though, the instrument is finished. So painful to be so close and be stuck waiting.

[Edited on 30-5-2014 by smaerd]




View user's profile View All Posts By User
aga
Forum Drunkard
*****




Posts: 7030
Registered: 25-3-2014
Member Is Offline


[*] posted on 30-5-2014 at 14:32


Unlikely that you fried your chips unles you heated them with a blow-torch !

Got a photo of the board ?




View user's profile View All Posts By User
smaerd
International Hazard
*****




Posts: 1262
Registered: 23-1-2010
Member Is Offline

Mood: hmm...

[*] posted on 31-5-2014 at 09:20


Well I was using a 100-120 watt iron, with a copper tip(original tip burned out so I replaced it with some 12 AWG solid core copper wire). Definitely burnt and melted some of the PCB along the way :(. Try not to judge too harshly by my poor soldering job this was the second circuit I've ever put on protoboard. I tried to heat the PCB more then the pin and apply little blobs of solder but it didn't work as well as I'd of liked it too. The iron I have isn't made for these kinds of tight connections either. I think the solder I am using might be bogus as well, it's "cold heat" solder... Not even sure where I got it from.

Would you prefer to have connections labeled because it looks pretty confusing to me?

The conglomerate of soldered wires leading to the negative supply is something I was doing to test whether the issue was related too my power supply/decoupling portion of the circuit(rebuilt it on another part of the board). Power supply was functioning fine. I tested around kind of quickly with a multimeter around the op-amp stages and I believe it was the transimpedance stage that appeared wonky. Was a few days ago so I can't remember exactly what seemed wrong with it(needed a break from it).

Also on the back of the board you'll notice some scratch marks between lines going to the IC. I did that with a razor because there appeared to be a small short in a few areas. I unfortunately do not have desoldering whick or a desoldering sucker thinking about improvising one, but might just go with soldering in sockets then putting in the chips. The LTC1050 has this pin called "EXT CLOCK INPUT" or something. I have no idea what it does and can't find technical information about it, but I think I may have shorted it at one point with this circuit as well. The last time I did that on bread board it fried the IC(goo leaked out of it?).



DSCN0977.JPG - 101kB DSCN0978.JPG - 112kB DSCN0979.JPG - 87kB

[Edited on 31-5-2014 by smaerd]

[Edited on 31-5-2014 by smaerd]

[Edited on 31-5-2014 by smaerd]




View user's profile View All Posts By User
aga
Forum Drunkard
*****




Posts: 7030
Registered: 25-3-2014
Member Is Offline


[*] posted on 31-5-2014 at 09:52


Not bad at all !

A good iron is a key tool in building stuff like this.
Personally i prefer a 50W iron. A lot of people say 25W is better.

Any stray solder joins were made by you and the soldering iron.
Easiest way to remove them is by you and the iron again - clean the tip and melt the stray join onto the iron, or swipe it away.
A solder sucker is also very useful at times.

Datasheet for the LTC1050 is here :-
http://cds.linear.com/docs/en/datasheet/1050fb.pdf

As stated on page 7, "When the LTC1050 operates without using an external clock, Pin 5 should be left floating".
So you leave it unconnected.
The sample PCB layout on page 6 shows the pin as unused (unconnected).

This chip uses a sample-and-hold technique, and needs a clock in order to work.
It has it's own built-in clock, running at 2.5khz.

Pin 5 is there in case you disagree with the designers, and want to clock it at a different frequency,
in which case you must supply your own oscillator, and shove the signal into pin 5.

I got an Arduino Uno kit today, so if you need any programming help, i can test here and send you code.
Doh. 'Sketches' then. All looks like programming to me ...

Quote:
using a 100-120 watt iron, with a copper tip(original tip burned out so I replaced it with some 12 AWG solid core copper

So yes, a Blow Torch then !

[Edited on 31-5-2014 by aga]




View user's profile View All Posts By User
smaerd
International Hazard
*****




Posts: 1262
Registered: 23-1-2010
Member Is Offline

Mood: hmm...

[*] posted on 31-5-2014 at 10:31


Thanks for letting me know about that pin. I mean I assumed that was it's function, just wasn't sure how it would respond to say 5V essentially D.C. being thrown at it or if it would need resetting :D. Just going to start fresh instead. The LTC1050's are great little op-amps but I thought about it and a lot of the performance I need could be handled with some cheaper more ubiquitous components. The non-inverting voltage gain stage, really didn't need to be an LTC1050, at all... Think a TL082 will do fine there. We'll see how the parts I spec'd out will do. Originally I wasn't fluent enough to actually decide on the chips, now I'm more confident in my decisions.

Yea pretty much a blow-torch hahaha. Thing can melt solder in 2-3 seconds which is way too much for a PCB or a sensitive IC. I'm going to go buy a cheapy 50watt I think just for future projects, not everything I do has to be improvised. Guess it's how I was raised. Wish I would of known about those DIP-8 sockets for protoboarding before doing this, live and learn.

Nice let me know how you like the Uno. I'm using a Leonardo. I'm okay on programming, well it was my first time doing anything with a microcontroller but I kind of have the hang of it. Spent many years writing code growing up, so that helped, and also helped with writing the front-end. Kind of crazy how you never really forget that kind of stuff. Arduino's are nice, as they are kind of higher-level("sketches") but there is access to the lower level stuff if you really want to dive into it. I definitely use the lower level digital read commands for speed (not that it's necessary but it makes me feel safer). Still need to implement my ADC stabilizing stuff for accurate readings but the circuit comes first before fiddling there. I was actually considering switching to a rasberry pi or beagle bone black just so I could really rip my motor and get all the data I wanted quickly. Even store said data, rather then relying on it passing through the serial pipe. Ultimately though, this will work fine.

If you plan on doing serial communication and get lost let me know. Big hint for me was downloading the arduino source-code and seeing how they handled everything (gotta love open-source, no need to break out the decompiler :P). I have some pretty decent integer passing algorithms and things(not that it's a difficult problem to solve, break them into 2 byte chunks and just pass them down). I can get you the source code I have to build off of, that's what community is for. It's in JAVA though, which I know most real programmers find horrendous, but the idea's are the same. I haven't cleaned up my code much yet, that's kind of a finishing touch type of thing. Function comes first.

[Edited on 31-5-2014 by smaerd]

[Edited on 31-5-2014 by smaerd]




View user's profile View All Posts By User
aga
Forum Drunkard
*****




Posts: 7030
Registered: 25-3-2014
Member Is Offline


[*] posted on 1-6-2014 at 00:26


Arduino is quite nice, in that it's very quick easy to get something started.
I can see now how they became so popular.

How i thought you'd do this project would be to use a stepper motor to control the rotation of the polarised filter.

First Calibrate, which would be to step around to the Least light intensity with no sample present, which would be the 0 point.
Then add the sample, go one step, measure, send data. Repeat for all steps in a full revolution.

A simple averaging ADC technique is to take a multiple of 2 samples each time, add that to an accumulator, then shift the resulting accumulator right N times to perform an ultra fast division.

i.e.
zero accumulator variables,
sample,
add ADC reading to accumulator,
repeat the sample/add 8 times
shift acumulator Right three times (=divide by 8)

You can refine that by storing each sample, and discard any results that are Way off, but that usually isn't necessary.

My preference is for Assembler, as you get to control exactly What is going on, and When.

The part i have never been any good at is getting the data into a form that the User can understand, especially in Windows.
If you could post an example of getting data from the arduino to a windows PC and display it, that would be really helpful.




View user's profile View All Posts By User
smaerd
International Hazard
*****




Posts: 1262
Registered: 23-1-2010
Member Is Offline

Mood: hmm...

[*] posted on 6-6-2014 at 08:43


Really sorry for taking so long on this. A lot of crazy things have been happening in my life. One was pretty bad but the other really good, give and take. Anyways, here is some source code for how I am handling serial passing.

Heres the threaded method I am using which checks for incoming serial data.
Quote:

public synchronized void serialEvent(SerialPortEvent oEvent) {
if(oEvent.getEventType() == SerialPortEvent.DATA_AVAILABLE){
try {
while (input.available() > 0) {
stillRecieving = true;
lowByte = input.read() & 0xff;
highByte = input.read() & 0xff;
transferredInt = (int) (highByte << 8 | lowByte);

if(IncomingData){//Data is being transferred quickly over serial
if(transferredInt >= 0 && transferredInt < 1024){//Data was sent
//recievedData.add(transferredInt);
dataHandler.addNewIntensityMeasure(transferredInt);
} else {//Instrument command was sent, not data (Initialize, measure, etc)
handleInstrumentMessages(transferredInt);
}
} else {//Instrument command was sent, not data (Initialize, measure, etc)
handleInstrumentMessages(transferredInt);
}
}
stillRecieving = false;
} catch (Exception e) {
System.err.println(e.toString());
}
}
}


Then I have a class(DataHandler) which consists of essentially an arraylist of integers(polarimeter intensity&rotation information) and some basic methods to handle such.

Probably the most important thing in that class for what you're asking about is the method that constructs the 2-D array of information that the graph GUI library can turn into a visual element of said data(using JFreeChart). JFree Chart is an exceptional library for Java for creating all kinda of charts/graphs etc. Royalty free, and honestly, has some performance too it(haven't clocked it), but charts that struggle in LibreOffice are nothing in JFreeChart. Shouldn't have even bothered with making spreadsheets should have just worked with the soft-ware could have saved hours.

Quote:

//Changes the received data in the integer arraylist
//to a double[][] so it can be used in a chart GUI element.
public double[][] getXYDataSet(){
int dataSize = recievedData.size();
double [][] newSeries;

if(dataSize > 0){
newSeries = new double[2][dataSize];
for(int i = 0; i < dataSize; i++){
newSeries[0] = (((double)i)/((double)halfRotationPulseCount)*180.0);
newSeries[1] = recievedData.get(i);
}
}else{//If Data array has no entries return blank XYdataset
newSeries = new double [2][1];
}
return newSeries;
}


That class also handles the harmonic regression analysis. If you wanted to see how I was going any of that just ask, it's pretty easy.

This is how I am populating/updating the graph and the 'DataHandler' class.

Quote:

private void populateGraph(String label){
DefaultXYDataset ds = new DefaultXYDataset();
double [][] newSeries = dataHandler.getXYDataSet();
dataHandler.clearDataCache();

ds.addSeries(label, newSeries);

cp.removeAll();
plot = ChartFactory.createXYLineChart("Measurement",
"Angle Of Rotation(Degrees)", "Intensity(AU)", ds,
PlotOrientation.VERTICAL, true, true, false);
cp.setChart(plot);
cp.setLocation(0, 0);
cp.setBounds(0, 0, 640, 320);

add(cp);
cp.repaint();
}



Assembler is probably the most powerful programming language. Again though it's so low-level, not very fast for testing things out.

I did get the new op amps(LF356N & TL082) and am testing circuits today to see what I can make happen on bread board. I'll let you know if I can get anything decent, other-wise it's back to the drawing board.

[Edited on 6-6-2014 by smaerd]




View user's profile View All Posts By User
 Pages:  1  ..  3    5    7  ..  9

  Go To Top