Computer GUI to Control Arduino/Adafruit

Let me know what you think.

http://youtu.be/hLEoRUAZ0uk

Hopefully, the ideas get across.

…now that’s cool…So

…now that’s cool…

So this code could be altered for another project to, for instance, create a different worded button, of a different shape if need be, that when pointed to an Output pin of MEGA (Uno too?) would activate a motor if pressed, or change the color of the button if an input were found to be high?  And is capable of Save-As with any changes for that other project?

The only thing that didn’t at first appear compatible in the YouTube video was the slider bars as you described them.  The hardware to move a motor would be set up with two relays, one for direction and the second to jog it in the direction chosen.  This made it intuitive when using the Firmata_Test derivitive code picture I attached recently and the button would change text In to Out when it was pressed and then the second botton made moved the motor move changing text from Stop to Start until is was clicked again to then read Stop.  There is a linear slide pot whose wiper is attached to the moving part associated with that motor and therefore it sends a variable voltage within the range of 0-5VDC to the analog input on MEGA and at the limits of travel there are dual throw switches that break the circuit to stop the motor in that direction and send 5VDC to an input on MEGA indicating limit reached.  The other motor direction is then the only option until the made limit switch is unmade.  That slide pot voltage is on an input and should be displayed as a bar graph of some sort giving some indication of where between the limits it is.  Again, the project as it was moving forward was made compatible with Firmata_Test and possibly something I could understand to create something for the next project.

Three motors would be set up this way with the fourth, the calibration mirror motor, not needing a slide pot because it will be in or out and never inbetween.  The calibration mirror motor would stop when its limit switch is reached sending that 5VDC to a MEGA input via the dual throw.

The Neon or Argon lamps are also set up on two relays, one is for choice and the other is to supply 120VAC to the chosen lamp.  The way it appears in the video is great as it has choice and on/off!

I’ll try to attach two pictures.  The first is the motor wiring integrating limits that stop the motor and send to inputs.  The second is the diagram of the system, showing the cable supplying power to the lamp calibration box and within it is also the voltage converters needed for the spectrograph box containing the circuit board of relays/transistors and MEGA.  The one is bolted to the other and amphenol conectors are used.  You’ll see the Grating Rotation was without limits, highlighted in red, and that was due to use of Uno.  MEGA provides enough pins now and this Excel file has not been updated due to not knowing if the project mechanics would get code.  All the parts except those within the bolded box labelled Spectrograph are done and the circuit board of relays/transistors is also done, just not the special order parts.

MTR_Wiring.jpg

Control_Wiring_Diagram.jpg

Let me attempt to answer your questions in order

You can change the wording of the buttons. You can change the shape, as long as it has 4 sides and 2 pairs are parallel to one another. I believe buttons could be given a shape, but, the shape would be due to an image, and, not actually be a different shape.

To explain, you might be able to use an image of a circle as the cover for a button. The actual button outline will still be square, but, what the user would see would be a circle. It would take a good bit more programming to make it work.

My thinking on the sliders is this, the slider will denote the position of the affected component. Since the computer will know where they are, moving the slider means the computer can tell them where to go. Hence, a slider moved to a particular position will both show where an object is, and, where it should move to. The control would all be in the programming. If the arduino is expecting specific outputs to tell it when and where to move, it can still receive them. But, if you really want buttons and scales. I can give that to you too.

It would seem that for the mirror object I could either leave the slider, and, it will show you where in the cycle between In/Out it is, or, I can add a couple buttons, and let the scale show you where it is, or, I can lose the scale, and just have a pair of buttons.

Color changing on command is no problem.

Ahhh, I see. Yes, I may

Ahhh, I see.

 

Yes, I may need the slider to only be a representation of approximately where within the limit switch range it is based upon the voltage seen on the wiper; 0VDC<x<5.0VDC.  To explain why, if I move the 36" diameter primary mirror in or out slightly in the collimation process of lining up all the optics, that forward or backwards movement then changes where the cone of light is within the range of the linear stage holding the slit, and the slit must be put at the cone point.  I’ll have the guiding CCD camera focused on the slit’s reflection (only the target starlight goes through the slit and starlight around the target is used for autoguiding or the remnent target stars light that couldn’t fit in the slit), so too if the stars are fuzzy because the cone moved I will need to move the linear bearing stage to a new position, at focus, and this becomes the new ‘0’.  If I were to see the slider value continue to creep up because collimation is a critical thing, then I’d remember next time to back the adjuster screws out, to bring the focus closer to the mid-point of the stage travel and the attached wiper.

There would be less of that type of movement for the rotational stage slider, minus the tangent error of a linear slider, but so too I’ll be viewing a pattern of brighter and dimmer lines of the Neon and Argon calibration light spectrum and determining the starting and ending wavelength seen on the main CCD camera, rotating the stage to get the right segment into view (I won’t be able to see frmo blue to red, only about 344 Angstroms.  If the lines happen to be blurry, the motor rotating the camera lens focusing the spectrum onto the main CCD is will be used to make it sharp.

For all aspects of setting up the system there’s a visual cue I will use to make appropriate adjustments, button clicks, except the calibration light mirror being entirely in the out position.  Where as the ‘in’ position shows me the calibration light spectrum on the main CCD camera I would definately need to see the ‘out’ limit switch made.  A slider is not needed there…

If it looked like this picture and worked I’d be dancing…

peanuts_dancing.jpg

Update

http://www.youtube.com/watch?v=uRLRpSGcJ0c

This is no April Fools joke. It just so happens I am updating this today. :) 

…that would have been

…that would have been cruel.  It looks amazing! :D  I’ve just notified the wife that lit looks like I’ll be spending some money on a slit, lenses, and the 1800 lines per millimeter grating…, now that some code really appears to be on the horizon.  They up until now haven’t been purchased because they are non-refundable and have very little value on the used market.  The 8" guidescope was just mounted on the 36" a couple weeks ago which will allow me to, with an auotoguider camera, verify the stability and accuracy of the scope’s tracking, with a goal of keeping a 30-50 micron star in a 35 micron wide slit.  The spectrograph will do it not through the C8 scope but rather with the reflected light off the slit’s backside (what doesn’t go through the slit), but I’ll get an idea of the magnitude of work to get the scope to the tracking level needed.

Wow, thanks again…

Steven

Update

http://www.youtube.com/watch?v=uPGkmKEC6mY

Let me know if there are any changes you would like me to make, or, if there is something you would like me to explain better. I can tell you that the button choices are not currently saved. I will be sure to set the program up to read the potentiometers before anything else happens. The drop down for Calibration Lamp Type is disabled. I don't understand how you need to set a pin for that particular label.

Sweet!The lamp power and

Sweet!

The lamp power and selection are each on separate relays.  The power is the easy one, the power, 120VAC, is on the NO contact so power is sent to one of two lamps on the second relay only when the power relay is energized.  The two lamps are on relay 2 and on the same pole but different throw directions; NC contact is Neon, and NO is Argon.  So when NO contact is held closed the Argon will light as long as Power relay button is pressed.  Each lamp has photoresistors currently wired to Arduino Analog Input pins.

 

Can the slide bars, if they are that length, get a number included to the right of the slide to show the rough position like 0 to 1000 (or something)?

 

My gosh, I can choose the I/O pin, save the I/O configuration (though I may have to re-choose the Com Port that’s ok), and it will come up with the same button names after rading the limit switch states and pot wipers?  And I can do a Save-As with whatever name I want (or does that require that I recompile?), and, if I’m clever I can rename buttons for some future robot board project as long as it’s MEGA (and again recompile?)?  How would I, for instance, change it from Telescope GUI to something else?

This is sooooo cool.

Thanks.

I will post a link to the current code.

http://pastebin.com/5tQUeTwY This link is set to expire in a month.
zip containing everything you “should” need https://dl.dropbox.com/u/28951892/Telescope%20GUI.zip except for
Python http://www.python.org/download/ 2.7.3
and, PySerial for the version (x86 or 64bit and 2.7) that you download from above http://www.lfd.uci.edu/~gohlke/pythonlibs/ (near the bottom 1/3 of the page)

Re: sliders. There is in fact code that will add numbers to the right of the sliders as they are updated.

I still have a fair bit of code that will get the program to talk to the arduino. I have one that I can use to test bits of code to get everything hopefully working.

Re: the Calibration Lamp - Type. I was mistakenly thinking this choice would need two pins. It does not. A single pin with output will be either Neon, or, Argon. The power pin above will control whether or not the lamp is turned on. A NOT gate will be required on the arduino end of this setup to make all of this work, then, the pins for Neon and Argon will have the responses from the photoresistors. Bottom line, I will reenable that pin selector.

Thanks, I’ve downloaded

Thanks, I’ve downloaded everything and I’ll try to install it.

Regarding the lamps, it’s 2-relay (2-button) configuration is the same as any of the motor 2-button.  The calibration lamp box already works with Arduino Uno using the Firmata_Test.  For the lamps, 2 output pins are used going to one of two relays.  They should make a button change to Off/On when de-energizede/Energized by the Arduino Output Pin.  The second Arduino Output Pin, same thing; output Off is set to NC contact on relay and energizing the lamp type Output Pin then closes the Contact enabling Argon.

Power-Lamp

0 - 0 =Off-Neon; No light comes on, so no detection on Input Pin with photoresistor so Power Button shows Off and Neon Button stays showing Off.

0 - 1 =Off-Argon; No light comes on, so no detection on Input Pin with photoresistor so Power Button shows Off and Argon Button stays showing Off.

1 - 0 =On-Neon; Neon light turns on and Input Pin Neon goes high so Power Button shows On and Neon Button changes from Off to On.

1 - 1 =On-Argon; Argon light turns on and Input Pin goes high so Power Button shows On and Argon Button changes from Off to On.

 

I don’t see a need to put an inverter on it, and really hope I don’t have too…

Thanks.

Ignore my inverter comment.

I was thinking out loud again. :stuck_out_tongue: I am trying to get this put together to your specs, so, I will attempt to learn to keep my opinions out of the setup. As I understand it now, The Neon pin, and, the Argon pin will be to read inputs from the phototransistor/photodiode to tell whether the Lamp is actually on, correct?

No worries…I was thinking

No worries…

I was thinking “But it works!?!  I saw it work…”  It’s a part of the project which is done so I’m glad it can stay.  I look at pictures I took of the circuitry in that box before I closed it up and am really glad I don’t have to open it again. :stuck_out_tongue:

I should use the button phrasings as you’ve shown too…

Name - Pin Type - Device - State - Button Phrases

Calibration Lamp Power - Output Pin - Relay - State 0/1 - Off/On

Calibration Lamp Type - Output Pin - Relay - State 0/1 - Neon/Argon

Neon Lamp - Input Pin - CdS LDR - State 0/1 - Off/On

Argon Lamp - Input Pin - CdS LDR - State 0/1 - Off/On

Yes, the Input Pins are just reading the LDR, so I actually know the lamp turned on because the two Output Pins to choose On and a lamp type might show it should be on but the LDR confirms it.

Have a great weekend.

Steven

Thanks birdmun, I copied all

Thanks birdmun, I copied all the files but the scope laptop is rather old and had an unusually small hard drive, so I’ll try to get them set up on my home-use laptop which one day will most likely be the one eventually mounted on the scope, moreso if the code is installed and works.  then a new home-use will be in the control room used to control the scope via remote desktop.  Is there anything I should look out for in installing all these files?

I hope not, but were you waiting on me for anything?

Thanks, Steven

One step closer…

While the construction of the spectrograph has not progressed, there was one big item needed from the telescope; autoguiding, accurate autoguiding.
The ServoCAT servo motor system was installed, but then, as its deficiencies were found it pretty much meant every single piece of hardware that came in the box had to be rebuilt to make a 1700-pound telescope move well (so the ServoCAT install is coming up on two years now but it has worked for visual purposes). Then, all the gears in the gear box of Alt and Az were put on the drill press and pinned to their shafts when I was finding set screws coming loose (only one per gear is absurd). And, in addition to that, extra brackets were made to eliminate sources of mechanical flexure causing backlash with using a spool and knurl on long shafts to move Alt/Az so that then software backlash compensation would only have to take care of the expected gear mesh slop and nothing more. http://darkskyobserving.com/ServoCAT.html. StellarCAT offers a Jr. and Deluxe model. Starting with Deluxe, what I’ve created is now the Monster model.

As such, I’m happy to say that just two weeks ago, after all was completed and installed I set the speed of the system software to 7.5-arcseconds per second, and, at 400x in a reticle eyepiece I did not see any noticeable delay when moving the scope or reversing the direction. My estimate is under 2-arcseconds of backlash. The software setting for backlash was set to zero.
Last night I battled the software drivers for Orion’s Starshoot Autoguider and it’s now working. Next time I go up to the property I’ll be seeing for the first time if the autoguider placed in the guidescope, a C8 bolted to the side of the 36", autoguides and I can look into an eyepiece in the 36" and see it stand totally still.
I appear to have nailed the backlash, if the motor/gears system is robust, to enable the the spectrograph project to continue.  The backlash problem was a project, enough to stop science from happening on the scope if the scope couldn’t hold a star still using autoguiding. 

Birdmun, may I ask for continued help in a self-installing disk that would contain the software parts needed for the GUI design as we’ve discussed to control the Arduino using buttons and sliders?