Guzunty / Pi

This repository contains resources to support the Guzunty Pi IO expansion board
110 stars 32 forks source link

NOOB Guzunty question #21

Closed Toshibass closed 10 years ago

Toshibass commented 10 years ago

Hi 24/12/2013 I asked santa claus to bring me one of these boards they look really great, however now I have a concern after reading all the details regarding set up, it appears that GPIO 4 is required to be used full time, is there any possibility to use some other pin, as my project needs gpio 4 to connect 6off DS18B20 temperature sensors and to my knowledge they will only work on this pin on the raspi, I would even consider purchasing say a RTC or something if this would make it possible to use both the Guzunty and one wire DS18B20 devices, unless of coarse it is possible to configure one of Guzunty pins to work with these temperature sensors? please advise thanks

03/01/2014 OK Guzunty arrived followed instructions on https://github.com/Guzunty/Pi/wiki/Construction-guide tried sudo./gz_test, works fine, tried loading some cores, all successful, looking at gz_16o8i loaded and test gz_16o8i.py working fine leds flashing like crazy, now I need some fundamental info, like a simple example of how to switch 1 output from 0 to 1 and read 1 input in python, just one snippet will do so I can extrapolate and get this board doing something useful, I cannot find anything on the web showing a thick noob how to get his head around this, which in reality is such a basic requirement I would have thought it would have been easy to include it in the getting started wiki, or is this board only for people with a brain the size of a planet ?

Regards and hoping for some feedback Toshi

Incidentally I would still like an answer to the above question please, or is the way forward to get a DS2482-100 based i2c to 1 wire host adapter for my ds18b20 temperature sensors?

campbellsan commented 10 years ago

Hi Toshi,

I thought your question about GPIO4 would be of general interest, so I answered it here:

http://www.raspberrypi.org/forum/viewtopic.php?f=41&t=49352&p=479625#p479625

Regarding the Python example. I'm happy to help, but I need to understand what is missing from the gz_16o8i.py program. Don't you just need to cut this program down to do just what you want?

I could do this for you, but you'll learn much more doing it yourself. And I'll be very happy to jump in and help if you do hit any problems.

Toshibass commented 10 years ago

I just came back to Guzunty after 4 months due to other commitments and was wondering if you had time to work on "adding a function to read a specific bit" being able to easily check the state of a individual output pins like if its currently 0 or 1 as well as checking state of an input pins, I can see GZ.spi_read() which returns 65535 but this doesn't change even when all outputs are energized I just don't get it please help.

campbellsan commented 10 years ago

Hi Toshi,

Let's first eliminate any hardware problems. Is the gz_16o8i.py program working as you expect?

Toshibass commented 10 years ago

Hi Campbellsan

Thanks for your response thought I had broken github by closing or something, anyway for sure the guzunty is working perfectly I like the board but at the moment its useless to me, I made a daughter board that plugs into the top of the guzunty with LED’s on 16 output pins see attached and I am now ready to continue the hardware side of things however I need to resolve my problem first:

Incidentally your test program flashes the LED’s just fine and reads the inputs, I didn't try connecting anything to the inputs yet.

In reality I only have any experience with python & js no other language, so from info you supplied, I can switch any of the output pins On or Off using the following :

Switch output 1 On

GZ.spi_set(1) # 0 to 15 time.sleep(5)

Switch output 1 Off

GZ spi_reset(1)

or

for x in range(0, 16): GZ.spi_set(x) time.sleep(0.1) GZ.spi_reset(x)

Great so far

What I need to be able to do is read the state of an output pin if its 0 or 1 and same for the 8 input pins

I guess to do this involves GZ.spi_read() and if I say print GZ.spi_read() I get 65535 (but always no matter which pins are set to 0 or 1 which I didn't expect) I tried GZ.spi_read(1) but get a syntax error spi_read() takes no arguments (1 given)

Also I tried the following which I was trying to extrapolate from your python test file: GZ.spi_set(4) GZ.spi_set(7)

pins = int(GZ.spi_read()) mask = 0x01 for i in range(16): if (pins & mask): # < and tried if (pins & mask)==1: print (pins & mask) print (i, mask,"1") else: print (i, mask, "0 FOUND")
mask = mask << 1

This tests address 1,2,4,8,16,32,64 128 256 512 1024 4096 8192 16384 32768 for 0 or 1 they all return 0 , I tried different values for mask and increasing the for loop to cover more addresses but in reality I have no idea if I am on the right track, I am just probing in the dark.

Thanks for any assistance you can give me

Best regards

Toshi From: campbellsan Sent: Tuesday, April 29, 2014 12:46 PM To: Guzunty/Pi Cc: Toshibass Subject: Re: [Pi] NOOB Guzunty question (#21)

Hi Toshi,

Let's first eliminate any hardware problems. Is the gz_16o8i.py program working as you expect?

— Reply to this email directly or view it on GitHub.

campbellsan commented 10 years ago

Hi Toshi,

I posted an answer to your question here:

http://www.raspberrypi.org/forums/viewtopic.php?f=41&t=49352&p=543002#p543002

Please let me know if it answers your questions.

best,

Derek

BTW, the small power circuit you posted looks good to me. It will of course still be subject to the overall Pi limit on the 5v supply. You can always use a separate supply and connect only the grounds together. That is what I do for some of my projects.

campbellsan commented 10 years ago

New bitwise read API added to the C and Python libraries. Python demo updated to use them.