Friday, July 29, 2016

Optical encoder basics

There are various complexities for optical encoders
I will be focusing on the more basic types.

For those of you who like a video see Video 1, this video covers some of the theory behind how an optical encoder works.However it does not cover of the application to the ROV project.
Video 1: Basics and how it works.

Here is a DC motor connected to an optical encoder. A DC motor isn't very accurate however it has the support and is inexpensive. 

An optical encoder improvises for the lack of accuracy. There are three basic parts to an optical encoder see figure 1.

  1. In the black rectangle on the left there is a laser or an LED to shine a beam of light.
  2. Also in the black box there is a gap under the LED or laser, and across that gap there is a photo resistor (light receiver).
  3. There is a rotary disk which fits in the gap between the laser or LED and photo resistor. The disc is transparent, there are hundreds or thousands of black lines to interrupt the light beam which is printed on this disc. I used a marker to enlarge these interrupt lines for visual effects see figure 2.


Figure 1: Optical encoder on DC motor


Figure 2: Optical encoder with enlarged interrupts


Not all optical encoders are the same see Figure 3. This is the optical encoder from my ROV. There are 50 black lines on this rotary encoder. since the encoder has low resolution you can see the lines in this figure. the light emitter and receiver's on the left.
Figure 3: Optical encoder from ROP project
Figure 3: Optical encoder from ROP project

In the optics the photo resistor can only see it's on and off state or and logic design a 1 or a 0.

If we wanted our motor to do a full rotation and there are 50 black lines, then we can rotate our motor until the logic of the photoresistor has seen a 1 50 separate times.

For those of you who are observant will notice that this is not the standard DC motor it is a servo, I unfortunately bought a cheap servo without an accurate built-in encoder.



But wait there are more little tricks to encoders, there is a way to get twice the resolution. Yes, that means 100 steps from 50 black lines. we have been saying that that light received is a 1 and that light interrupted is a 0 see Table 1. 

To double our resolution we used the rising and falling edge of each black line. One example, the transition from not receiving light to receiving light has a value of one, however both light received an light interrupted as a value of zero see Table 2.

State of Florida resistor
Light receives
Light interrupted
Logic value
1
0
Table 1: logic values first case


If you find the case in Table 2 difficult to understand consider watching Video 1 at time 2:20 (Here).
Photo resistor
Light received
Light received transition to light interrupted
Light interrupted
Light interrupted transition to light received
Logic value
0
1
0
1
Table 2: logic value second case

To see a demo for arduino code click (here)
On line ~25 you will see 
attachInterrupt(digitalPinToInterrupt(servoEncoder), AirServoEncoder, CHANGE);
The attach interrupt has works different on different arduinos. You can fine fore detail on arduino's site (here)

Attach interrupt allows the program to monitor a pin while doing other tasks. The controller could spend all of its time monitoring one pin awaiting a signal that will be so fast that just about any other way the signal would be missed. But there is one other thing we can do, that is an attachInterrupt. 

When an event happens while running a different part of the program, this interrupt will make a note of the missed event to run a designated function when it can make time. 

In my case going back to 
attachInterrupt(digitalPinToInterrupt(servoEncoder), AirServoEncoder, CHANGE);
this says when there is a "CHANGE" to "digitalPinToInterrupt(servoEncoder)" pin nomater where the program is running go to "AirServoEncoder" program.

The referenced program has to be as simple as possible without any delays or any thing that can act like one. My referenced program is "AirServoEncoder" and the only line of code in it is on line ~52 "encoderCount++;" then my loop will reference the int encoderCount for posichaning. The int encoderCount is a count of how many stamps have been seen.

Here is a side view of the servo, encoder, adapter, and air regulator for my remote-controlled submarine's air system see Figure 4. The cylinder on the top of the picture is the bottom of my air regulator, right under that is my 3-D printed (soon to be cast aluminum) adapter to fit to the top of the servo. It's difficult to see in this picture of the encoder is placed between the servo and of the adapter.

Figure 4








Thursday, July 7, 2016

Air system – pressure regulator – servo – adapter – 3-D model

 Air system – pressure regulator – servo – adapter – 3-D model

This is a temporary adapter to convert the top of the servo to a 3/16 hex bits.

For better understanding of the application of this piece, you can visit my YouTube channel (here).




I've 3D printed this. The plan is to make a metal casting in order to handle more torque. The 123D model is available (here) And if he STL files will be given (here) with more details.

This piece is used to regulate the pressure using its 3/16 hex bit. That mounts on top of the servo and attaches to the bottom of the pressure regulator. On my design I also include an optical encoder to the base of the adapter.


Friday, May 27, 2016

Improvising

I think I need a camera mount.... I'm surprised this actually worked, balancing a camera on the lab to film a video.

I didn't know I ever take a picture of this. My first remote vehicle.

This is my first remote vehicle

This was my first remote vehicle. I went digging through our house and found an old remote-controlled car. To my brother's dilemma that is now the chassis. Nothing too great about this but it was lots of fun.

The original computer-chip was pulled out after a failed attempt at hacking it(and the release of the magic smoke). This was driven by Bluetooth.

If I were to go back and redo this project I would have to design it with a watchdog timer. I would give it a command through my computer or cell phone and it would operate on the command Until it either was terminated or it was updated with a new command.

When the remote control car was too far for Bluetooth it would continue operating on the last command, even if that command was full speed ahead. You'll notice the ultrasound module on the very front, this was an attempt to run into less stuff at full speed….

Monday, May 16, 2016

Building Remote Operated Underwater Vehicle introduction

Here it is. I have finally I have finally got my channel up and my first video posted. This channel will be used as a visual aid station keep up and hopefully duplicates parts of my project.




Tuesday, April 26, 2016

New Weekly update

It turns out I have an audience of one. It's been suggested that I explain the steps better have a larger view of the overall project. To accomplish this I will attempt to make each segment of the process duplicatable. I've been heavily considering making short videos to go along with the text. He will come to find that my video editing skills are even worse than my spelling.

Tuesday, April 12, 2016

Air systems optical encoder

The servo does not have a built-in encoder :-(, this has proven to be an inconvenience because the servo motor for the era regulation does not move linearly with increased load. The optical encoder will improvise for this sluggish movement.

The key to every mystery is a simple as finding data points. More data points you have: the more he will know about the mystery.

My mystery is also battle, I cannot move at a high radial frequency because my sample rate is too slow and resolution relatively unknown which I will get to momentarily. I can designate a separate microcontroller to the optical encoder, by servo with an encoder, or decrease my resolution of the encoder but keep it in with my desired accuracy.

How accurate do I need it? Back to that whole making data points to solve the unknown. Here it is see Figure 1:


Figure 1: pressure versus degrees of rotation by the servo.


My graphics in figure 1 seem to me missing some crucial data this can now be found in Table 1.
Radial degrees
Test 1 atm
Test 2 atm
Test 3 atm
1.0
1.1
1.1
60°
2.1
2.0
2.0
120°
3.6
3.5
3.4
180°
5.1
4.8
4.9
240°
6.6
6.4
6.3
300°
7.8
7.6
7.6
360°
9.1
8.6
8.8
420°
10.5
10.1
10.3
480°
11.8
11.6
11.7
540°
 n/a
 n/a
13.0
600°


14.4
660°


15.9
720°


17.9
780°


19.4
840°


21.0
900°


22.6

Table 1: radial degrees first pressure plot.


There are some data points but I am limited by my temporary pipe system which is only supposed to handle 8.2 ATMA (~100psig). The second it as a pressure test shortly after reaching the 16 ATMA I had a joint start leaking air.

Test 1 may have some extra and accuracy from my air tank rotating.

Test 2 corrected errors than the of occurred and test one.

Test 1 and 2 were only brought slightly above the maximum suggested pressure.

Test 3 was pushed further than the maximum suggested pressure mainly the first third visualize the linear reality of the pressure regulator.

Conclusion I will need a minimum resolution of 87 nooks. Note: 0.1 ATM is this lowest acceptable resolution as used in this calculation.

Case Test 1: 480°/10.8atm = 4.44°/0.1atm =>360°/4.44° = 81 nooks.

Case Test 2: 480°/10.6atm = 4.53°/0.1atm =>360°/4.53° = 80. nooks.

Case Test 3: 900°/21.6atm = 4.17°/0.1atm =>360°/4.17° = 87. nooks.


I will go with Case Test 3 results, because they are the least favorable. To further simplify future arithmetic and to have a little above the minimum I will go with 100 nooks.

Here's a link to a site which generates optical encoders:http://www.bushytails.net/~randyg/encoder/encoderwheel.html

The could be some small improvements to the site but I'm not about to write one myself so I'll deal with it and imagine you'll do the same. After plugging chunking and redoing I came up with my optical encoder see Figure 2



Figure 2: optical encoder image with 100 steps.

How does an optical encoder work click (here)

Sunday, February 7, 2016

A new function has just been started as an emergencystop.

This is a link to the emergency stop function.

http://rovjacobsnotes.blogspot.com/p/emergencystop-function-in-balisktank.html

For now all that it does is turns my servo. Later I may huck a watchdog timer.

Wednesday, February 3, 2016

Servo 1.1 four main code pressure regulator

I will be adding my server 1.1 Arduino code into my ballast tank test code.

In the process of converging these two codes I will make notes on what comments have been added to which lines. Note it's unlikely the lines will say the same but the general area or functions well in laissez later remark specifies.


  • Line 8 #include <Servo.h> --Remove from line 8; already in previous code online 79 under loop
  • Line 41 String serial;// Used in AirRegulatorServo()
  • line 42 add Servo myservo;// Used in the air systam sorvo. see about oving this.------------------
  • Line 49 myservo.attach(9);// Used in AirRegulatorServo() Set Pin, Defalt: 9. ------------------------See about moving this into the function AirRegulatorServo(). At a later time
  • Line 134 Add reference to AirRegulatorServo(serial); under loop------------------------------------- see about adding a condition to running this function.
  • Line 582 Add function 
int AirRegulatorServo(String serial){
  
   }
   else serial = "90";
  
  
  if(serial.toInt()<90){
    myservo.write(serial.toInt()-4);
  }
  else myservo.write(serial.toInt());
delay(500);// Temp remove after tested.
}
This will be modified at a later time.

This function is still in progress and will be updated regularly here on my online notebook.


Momentarily problem the servo is spending without apparent merit.
Partial solution by default serial is zero and not what's required for stationary which is 90.


  • Line 115under loop change serial = "0" to serial = "90". 



Air regulating servo

Air regulating servo


The servo will be used to manage the pressure regulator. The servo SM-S4315R has the capability of continuous rotation and is ideal for this application figure 1.


Figure 1: SM-S4315R servo

The code used is available (here). This shows the basic functionality. In order to have the servo rotate clockwise send a integer between 0 and 89, to prevent the servo from rotating send 90 via serial port, and to rotate counterclockwise any integer between 91 and 180. Farther the number is from 90 faster the servo will rotate.

Click (here) for more details.