Celestial_Mech
Posts: 12
Joined: Tue Feb 07, 2017 1:24 pm

Gertbot and potentiometer feedback

Thu Mar 30, 2017 6:30 pm

Hi
I've got a linear electric actuator that has a potentiometer output for position. Is it it possible to read an analogue input like that on on the I/O, so I can then use it for feedback?
Thanks
Robin

User avatar
Gert van Loo
Posts: 2440
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Gertbot and potentiometer feedback

Fri Mar 31, 2017 6:53 am

The answer is a simple: yes.
You need to connect the analogue signal to the A/D converter input.
Then use the Raspberry-Pi SPI interface to read from it.

(Sorry for the late reply. I just realised my notifications where going to an old email address)

Celestial_Mech
Posts: 12
Joined: Tue Feb 07, 2017 1:24 pm

Re: Gertbot and potentiometer feedback

Wed Apr 12, 2017 9:33 am

Excellent, is this where the pins need to be reassigned for the Gertbot, or do some communicate directly to the RPi?

User avatar
Gert van Loo
Posts: 2440
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Gertbot and potentiometer feedback

Wed Apr 12, 2017 1:48 pm

Celestial_Mech wrote:Excellent, is this where the pins need to be reassigned for the Gertbot, or do some communicate directly to the RPi?
Sorry, I don't understand the question.

Celestial_Mech
Posts: 12
Joined: Tue Feb 07, 2017 1:24 pm

Re: Gertbot and potentiometer feedback

Wed Apr 12, 2017 1:59 pm

I was thinking that I had to release the pins from their duties on Gertbot to make them directly available to RPi. However reading further I take it that is not the case, but I can't quite see how one would access the analogue in data.

User avatar
Gert van Loo
Posts: 2440
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Gertbot and potentiometer feedback

Wed Apr 12, 2017 2:14 pm

The raspberry pi pins have to be assigned to be in "SPI-mode". That is: they are controlled by the SPI interface in the PI.
Then on the gertboard you have to connect them, using the wires, to the SPI interface of the AD-chip.
Next the SPI block inside the Pi needs to be instructed using C or python to perform reads or writes.
In this case you do a read from the ADC to read the 'analogue value register' from the ADC chip.
The analogue value will then be transferred from your ADC chip to the PI where you can read it from the SPI receive register.
Last edited by Gert van Loo on Wed Apr 12, 2017 9:53 pm, edited 1 time in total.

User avatar
Gert van Loo
Posts: 2440
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Gertbot and potentiometer feedback

Wed Apr 12, 2017 9:52 pm

Major correction!!!
I have been reading this as "gertboard" and potentiometer feedback.
Only now do I see it is gertbot and potentiometer feedback.

To use a potentiometer and gertbot do the following:
You set up one of the gertbot pins in ADC mode and then read the value back.
Most people seem to use the board with python.
This is code which reads back all four ADC pins each five times:

Code: Select all

   board = 0
   for i in range(13,17) :
      gb.set_pin_mode(board,i,gb.PIN_ADC)
   print("Five times ADC's read from BOARD0 !!!\n")
   for i in range (0,5) :
      print("ADC0 : %6.3f\n" % gb.read_adc(board,0))
      print("ADC1 : %6.3f\n" % gb.read_adc(board,1))
      print("ADC2 : %6.3f\n" % gb.read_adc(board,2))
      print("ADC3 : %6.3f\n" % gb.read_adc(board,3))
For feedback you need to read the value and then use the value read to send a command
to control one of the many parameters of the board.
e.g. you can read a potentiometer and then control the speed & direction of a motor.

Celestial_Mech
Posts: 12
Joined: Tue Feb 07, 2017 1:24 pm

Re: Gertbot and potentiometer feedback

Sun Apr 23, 2017 7:38 pm

Thanks Gert, no probs!
That looks easier to tackle too.
Best
Robin

Return to “Gertboard classic”

Who is online

Users browsing this forum: No registered users and 2 guests