OLED Displays with ...
 
Notifications
Clear all

OLED Displays with Arduino - I2C & SPI OLEDs

34 Posts
7 Users
4 Reactions
20.5 K Views
Bradscopegems
(@bradscopegems)
Member
Joined: 3 years ago
Posts: 35
 

And here is a rough diagram of the connections, which might be useful.

Connections for OLED servo rot encoder17092026 0001

 



   
ReplyQuote
Bradscopegems
(@bradscopegems)
Member
Joined: 3 years ago
Posts: 35
 

Abject apologies from me. The ino file I posted was not the correct one. Since my attempt to give the correct file a more sensible filename evidently did not work, I am resending the ino file that  I have test ed on two Arduino Uno r3 units, with the original rather silly filename: it is a modified form of the first version I was sent by the AI. The new ino file, called Claudsfirst_sep17a definitely runs properly and the drawing showing the connections that I sent is correct.  A slight disappointment with the performance has been revealed by my use of a more accurate angle scale: if the display shows zero degrees and the angle scale is set to match this and the encoder is then rotated to bring the display to 90 degrees, the angle scale shows 96. Then, setting the display to 180 gives an angle of 184. But resetting the display to zero by means of the encoder still shows exactly zero on the angle scale. This error is insignificant  in my application but in case I need better performance in future I am going to investigate the more conventional approach of encoder-stepper motor with homing plus OLED count of steps. I have prepaid for a month of the AI and will report back if I make any progress during my period of access to this amazing AI: Chatpro.ai-pro.org,  cost £90 sterling per month. After asking me a few questions about my requirements it took about 4 minutes to come up with the code

 It had made a mistake in the initial section about connections, with no Vcc going to the rotary encoder, but this was easily corrected.

    Once  again, I do apologize to anyone who tried my previous ino file. The attached one definitely is the right one. You may need to change the text size and cursor position to get the display at maximum size without omitting the final numeral. I deleted lines 77-79 because I did not want to waste space on my tiny 64x32 OLED by displaying the title 'Servo Angle'. You may need to  reset the cursor position x and y. Text at size 3 was perfect for filling my small OLED.

Brad



   
ReplyQuote
Bradscopegems
(@bradscopegems)
Member
Joined: 3 years ago
Posts: 35
 

Abject apologies from me. The ino file I posted was not the correct one. Since my attempt to give the correct file a more sensible filename evidently did not work, I am resending the ino file that  I have test ed on two Arduino Uno r3 units, with the original rather silly filename: it is a modified form of the first version I was sent by the AI. The new ino file, called Claudsfirst_sep17a definitely runs properly and the drawing showing the connections that I sent is correct.  A slight disappointment with the performance has been revealed by my use of a more accurate angle scale: if the display shows zero degrees and the angle scale is set to match this and the encoder is then rotated to bring the display to 90 degrees, the angle scale shows 96. Then, setting the display to 180 gives an angle of 184. But resetting the display to zero by means of the encoder still shows exactly zero on the angle scale. This error is insignificant  in my application but in case I need better performance in future I am going to investigate the more conventional approach of encoder-stepper motor with homing plus OLED count of steps. I have prepaid for a month of the AI and will report back if I make any progress during my period of access to this amazing AI: Chatpro.ai-pro.org,  cost £90 sterling per month. After asking me a few questions about my requirements it took about 4 minutes to come up with the code

 It had made a mistake in the initial section about connections, with no Vcc going to the rotary encoder, but this was easily corrected.

    Once  again, I do apologize to anyone who tried my previous ino file. The attached one definitely is the right one. You may need to change the text size and cursor position to get the display at maximum size without omitting the final numeral. I deleted lines 77-79 because I did not want to waste space on my tiny 64x32 OLED by displaying the title 'Servo Angle'. You may need to  reset the cursor position x and y. Text at size 3 was perfect for filling my small OLED.

Brad



   
ReplyQuote
Bradscopegems
(@bradscopegems)
Member
Joined: 3 years ago
Posts: 35
 
rotary encoder controlling servo operated iris

Since a few people have looked at this, I just wanted to finish with photos showing the servo controlling a photographic iris for use in a confocal microscope. With correct arm lengths and a bent non-standard brass strip as a link, the 180 degree shift of the servo maps on to the 90 degree range of the iris. The lower photo shows the box containing the Arduino, and the OLED shows the position of the servo arm at 64 degrees. At 0 degrees the iris opening is sub-millimeter and at 180 it is fully open. In my previous posts the Claudsfirst_sep17a.ino is the sketch that controls everything: ignore the earlier code I sent in error. In my hand-drawn image the connections are all correct, except the power input  ( from a 9v regulated DC transformer) via the barrel jack on the Arduino is not shown. The 5.1v input to the servo can supply 2 amps, which should be more than sufficient.

This setup is based on the DroneBot article on Using servo motors with rotary encoders. I am delighted that the cheap and simple setup works even though it has no homing switch. The position is set absolutely by the pulse-length supplied to the servo by the Arduino but the rotary encoder, with its two outputs, tells the Arduino whether the motor has gone clockwise or anticlockwise, so the Arduino can count how many steps the motor has taken. I was surprised to find that I could not confuse it even by spinning the encoder in alternate directions rapidly, though it is just a cheap one. When the motor and Arduino are switched on the servo always goes to the 90 degree position, which makes a convenient starting point for imaging, though perfect confocal microscopy needs a sub-millimeter iris diameter:  the larger iris settings are nevertheless useful if the fluorescence of the specimen in the microscope is very faint. I suspect that this program , including a nice OLED display, might be useful for all sorts of robotic movements. Just in case, I bought an expensive optical encoder but it looks as if I won't need it.



   
ReplyQuote
Page 3 / 3