BBC BASIC
« GPIO pins »

Welcome Guest. Please Login or Register.
Dec 12th, 2017, 1:02pm


Cross-platform BBC BASIC (Win32, Linux x86, Android, Mac OS-X, Raspberry Pi)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: GPIO pins  (Read 191 times)
bbott
New Member
Image


member is offline

Avatar




PM


Posts: 7
xx GPIO pins
« Thread started on: Aug 4th, 2017, 3:44pm »

Hi Richard, got BBC Basic working and have run your GPIO programme. I'm using GPIO4 to read a temperature sensor, but I am not sure of you functions for getting values from the pins, is there any documentation I can look at?
Barry
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 646
xx Re: GPIO pins
« Reply #1 on: Aug 4th, 2017, 4:23pm »

on Aug 4th, 2017, 3:44pm, bbott wrote:
Is there any documentation I can look at?

Currently, there are only the comments in 'gpiolib.bbc' itself. For the FN_gpio_get() function it states that you pass a pin number in the range 0 to 31 and the function returns either 0 if the pin is low or a non-zero value if the pin is high:

Code:
      REM Return the state of a pin (0 <= P% <= 31):
      DEF FN_gpio_get(G%,P%) = G%!&34 AND 1<<P% : REM 0 if low, 1<<P% if high 

So to get the state of GPIO4 you would pass 4 as the pin number. Is that what you needed to know?

Richard.
User IP Logged

bbott
New Member
Image


member is offline

Avatar




PM


Posts: 7
xx Re: GPIO pins
« Reply #2 on: Aug 6th, 2017, 2:20pm »

thanks RIchard, I'll try that and see what I can get.
Barry
User IP Logged

michael
Full Member
ImageImageImage


member is offline

Avatar




PM


Posts: 125
xx Re: GPIO pins
« Reply #3 on: Nov 27th, 2017, 4:32pm »

Quote:
Currently, there are only the comments in 'gpiolib.bbc' itself. For the FN_gpio_get() function it states that you pass a pin number in the range 0 to 31 and the function returns either 0 if the pin is low or a non-zero value if the pin is high:


That range should be 0 -255 ?

I'm guessing from the documentation the GIPO pins should be able to read the resistance value from a photo resistor or a temperature sensor or an ultrasonic distance sensor.. and other variable resistance voltages
« Last Edit: Nov 27th, 2017, 4:33pm by michael » User IP Logged

I like reinventing the wheel, but for now I will work on tools for D3D
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 646
xx Re: GPIO pins
« Reply #4 on: Nov 27th, 2017, 6:48pm »

on Nov 27th, 2017, 4:32pm, michael wrote:
That range should be 0 -255 ?

As far as I'm aware the comments are correct and the range is 0-31 (only 28 of those 32 corresponding to 'real' physical pins). There's a nice illustration, including the GPIO pin numbers, here.

Quote:
GIPO pins should be able to read the resistance value

You'd need an external ADC for that, presumably. The GPIO pins are all 'digital' aren't they?

Richard.
User IP Logged

michael
Full Member
ImageImageImage


member is offline

Avatar




PM


Posts: 125
xx Re: GPIO pins
« Reply #5 on: Nov 27th, 2017, 7:42pm »

Quote:
ADC for that, presumably. The GPIO pins are all 'digital' aren't they?


I have set up all of these systems before on the Arduino and it was measured on the analog pins. Essentially, it should be a matter of wiring on the bread board in this order:

GND to 10k resistor,analog sensor(digital read wire), photo resistor, to positive to 3.3v positive.

The Ultrasonic distance sensor and temperature sensor have similar set up method. I have made videos for those. I also have made videos for relay controls.

I believe if the GPIO pins can return a voltage sense (3v) then they can be used to track the voltage levels returned by the devices.

In that example it is just a button detection..

I would probably get this ADC or maybe a cheaper one from a different supplier:

https://www.bc-robotics.com/shop/16-channel-analog-input-hat-for-raspberry-pi/

The GPIO pin 24 I believe is also an analog pin.

The Pi3 is by far a simpler system to program and I have looked over the automation training docs.. Its essentially the same..

I am doing research on how people do it on Pi3.. I seen one example where they used a capacitor..

« Last Edit: Nov 27th, 2017, 11:18pm by michael » User IP Logged

I like reinventing the wheel, but for now I will work on tools for D3D
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 646
xx Re: GPIO pins
« Reply #6 on: Nov 27th, 2017, 9:20pm »

on Nov 27th, 2017, 7:42pm, michael wrote:
I believe if the GIPO pins can return a voltage sense (5v) then they can be used to track the voltage levels returned by the devices.

The electrical specification of the I/O pins on the relevant chip is here. As is typical of 'TTL-compatible' devices, a logic '0' must be <0.4 V and a logic '1' >2.4 V. You must not apply a voltage between these two thresholds for more than a few microseconds at most; if you do it can result in the input gate drawing excessive current from the supply or oscillating - or both! This may damage the device.

It seems from that specification that it is possible to configure the input gate as a Schmitt-trigger under software control, but I don't know whether the RPi software normally does this or not. If it does it may provide some protection from applying intermediate voltage levels, but it would make it useless as a 'pseudo-analogue' input because of the hysteresis.

Digital means digital! If you want to measure or detect an analogue signal you need to use a separate ADC. I have more than 30 years experience as a hardware design engineer, so I know what I am talking about.

Quote:
The GPIO pin 3 I believe is also an analog pin.

It is an I2C pin according to all the references I have seen.

Richard.
(M.A. C.Eng. M.I.E.T.)
User IP Logged

michael
Full Member
ImageImageImage


member is offline

Avatar




PM


Posts: 125
xx Re: GPIO pins
« Reply #7 on: Nov 27th, 2017, 10:20pm »

Ah yes. I looked in the manual and for Input lesson it has the power wire on the 3.3 v and the GPIO pin they are using for input is 24. It does require a 10k resistor in the construct .

Page 164 and 165 of your Pi manual.

Quote:
Digital means digital! If you want to measure or detect an analogue signal you need to use a separate ADC. I have more than 30 years experience as a hardware design engineer, so I know what I am talking about.


Here is the Pi ADC you speak of:

https://www.bc-robotics.com/shop/16-channel-analog-input-hat-for-raspberry-pi/

I wish I had your skill set.

Ill end up needing to order that part and other relevant parts to get things set up proper. Ill research this in depth

Ill fix the last post to prevent confusion.

I guess I took for granted the Pi would have the same basic voltage for electronic connections as the Arduino..

I was surprised that even the LCD example was all 3.3v..

Good thing you corrected me before I pulled out my parts and wired up 5v!! You are awesome Richard!

The 7 inch touch screen wires to 5v according to specs.

( I really looked carefully before I did any operations. I, like anybody, don't want to ruin over $300 worth of stuff.)



« Last Edit: Nov 27th, 2017, 11:21pm by michael » User IP Logged

I like reinventing the wheel, but for now I will work on tools for D3D
Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Donate $6.99 for 50,000 Ad-Free Pageviews!


This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls