Go to advanced search

by SavagePi
Mon Aug 18, 2014 8:22 pm
Forum: Automation, sensing and robotics
Topic: GPIO port 'Bit' order
Replies: 5
Views: 856

Re: GPIO port 'Bit' order

joan & rpdom. I understand both of your replies and I know how to turn stuff off and on. rpdom: I'm not looking to 'unlearn' everything I've ever learned. Even in the standard world of 8-bit or 16-bit world of interfacing, every 'bit' has always had its own designated function depending what it's be...
by SavagePi
Mon Aug 18, 2014 8:00 pm
Forum: Automation, sensing and robotics
Topic: GPIO port 'Bit' order
Replies: 5
Views: 856

GPIO port 'Bit' order

I'm writing a 'standard' function for use in all my projects that access the GPIO ports, and I was wondering... Is there, or has there ever been a 'standardised' bit order for the GPIO ports? As an example, the Gertboard uses the following ports for bits '0' through to bit '11' respectively... GPIO2...
by SavagePi
Thu Jul 10, 2014 8:53 pm
Forum: Python
Topic: Retaining variables within functions
Replies: 27
Views: 3348

Re: Retaining variables within functions

I'll take that as a compliment, AndrewS. Thank you.
by SavagePi
Thu Jul 10, 2014 6:39 pm
Forum: Python
Topic: Retaining variables within functions
Replies: 27
Views: 3348

Re: Retaining variables within functions

Thank you to everyone for all of your help, advice and suggestions. I really appreciated you taking the time. This has all been very informative and a bit of a 'learning curve' for me. BTW: Did I mention that I'm a Newbie to Python? :? But it all gives me something to work on. Thanks again.
by SavagePi
Sat Jul 05, 2014 9:02 pm
Forum: Python
Topic: Retaining variables within functions
Replies: 27
Views: 3348

Re: Retaining variables within functions

Try this, When calling the function use Z = any_function(x,y) And a the end if the function use Return (z) I've thought of using that method too, gordon77 , but I wanted just the function alone to control the variable. Which I now understand cannot be done ;) Nevertheless, thank you for the suggest...
by SavagePi
Sat Jul 05, 2014 7:55 pm
Forum: Python
Topic: Retaining variables within functions
Replies: 27
Views: 3348

Re: Retaining variables within functions

How the interpreter works is irrelevant. The language syntax takes a non obvious approach to scope, using the keyword global in a very non-intuative and inconsistent way. See if you can predict what this code will print.... #!/usr/bin/python y = 0 z = 0 numbers = {} def testscope(): global y x = 10...
by SavagePi
Sat Jul 05, 2014 6:35 pm
Forum: Python
Topic: Retaining variables within functions
Replies: 27
Views: 3348

Re: Retaining variables within functions

No. that's the point I was making. These are weak parts of the language that mix up the concepts of global and static variables. PeterO That's a valid point PeterO . I suppose the 'weak' part of the language is the way the Python interpreter stores (or doesn't store) variables. Since variables with...
by SavagePi
Sat Jul 05, 2014 3:11 pm
Forum: Python
Topic: Retaining variables within functions
Replies: 27
Views: 3348

Re: Retaining variables within functions

This is a weak part of the language :-( PeterO No, hiding a global variable (and calling it "static") inside a function is just an eyewash. I have no idea what you mean by "eyewash" in this context but you seem to not understand the meaning of "static" (at least not in the way it is used in "C"). P...
by SavagePi
Sat Jul 05, 2014 1:42 pm
Forum: Python
Topic: Retaining variables within functions
Replies: 27
Views: 3348

Re: Retaining variables within functions

Put "x = 0" on top of your script (making it a global variable of the module) start your function with global x Then your changes to x will be written to the global variable x I was thinking of doing that, gkreidl , and it is an option, I agree. But I'm not fond of globalising 'variables' and chang...
by SavagePi
Sat Jul 05, 2014 1:04 pm
Forum: Python
Topic: Retaining variables within functions
Replies: 27
Views: 3348

Retaining variables within functions

My apologies if this question has already been answered elsewhere, but searching the forum doesn't seem to come up with anything. As a newbie to Python, I was wondering if it's possible to retain variable values within functions, rather than getting the 'UnboundLocalError: local variable 'x' referen...
by SavagePi
Sun Jun 29, 2014 3:06 pm
Forum: Automation, sensing and robotics
Topic: 35 LED or Relay Outputs - 2 GPIO's
Replies: 2
Views: 1187

Re: 35 LED or Relay Outputs - 2 GPIO's

Interesting, thanks for this. It's sad that support for seven segment displays is dwindling. As you mention the MAX7219 is popular, but getting more and more expensive. I suppose SSDs will go the way of the Pixie tube eventually. Good heavens, I'd forgotten about pixie tubes. That'll be my next pro...
by SavagePi
Sun Jun 29, 2014 11:44 am
Forum: Automation, sensing and robotics
Topic: 35 LED or Relay Outputs - 2 GPIO's
Replies: 2
Views: 1187

35 LED or Relay Outputs - 2 GPIO's

Here's a design using an old and probably little known IC these days - the MM5451N. It's probably obsolete now, but you can still get hold of it. It was originally designed to drive the cathodes of 35 LED's, more specifically, five 7-segment LED displays and was widely used in automation because of ...
by SavagePi
Wed May 28, 2014 4:22 pm
Forum: Other projects
Topic: 16 Channel GPIO Input Expander
Replies: 26
Views: 3131

Re: 16 Channel GPIO Input Expander

Hi, I doubt. These signals don't drive any outputs (loads). I'd assume you have either broken chip or there is a connection/junction mistake. Best wishes, Ivan Zilic. I agree with Ivan here. This situation shouldn't be a problem with the 4067. As I mention in my PDF version, this mainly occurs with...
by SavagePi
Tue May 27, 2014 8:30 pm
Forum: Other projects
Topic: 16 Channel GPIO Input Expander
Replies: 26
Views: 3131

Re: 16 Channel GPIO Input Expander

Not at all, boyoh. The assignment of the GPIO bits are purely for convenience of programming: GPIO25 = A (1) GPIO24 = B (2) GPIO23 = C (4) GPIO22 = D (8) It actually doesn't matter which GPIO ports are used, as long as they're defined in the first place. The reason I defined them in reverse order wa...
by SavagePi
Tue May 27, 2014 6:39 pm
Forum: Other projects
Topic: 16 Channel GPIO Input Expander
Replies: 26
Views: 3131

Re: 16 Channel GPIO Input Expander

I understand that, Ivan. And I explained this in my PDF version... http://www.carol-anne-dolls.co.uk/Raspberry%20Pi%20GPIO%20Input%20Port%20Expander.pdf I know it's not important in this particular application. But it's important that users know about the general use of CMOS IC's. Also, what would t...
by SavagePi
Tue May 27, 2014 6:17 pm
Forum: Other projects
Topic: 16 Channel GPIO Input Expander
Replies: 26
Views: 3131

Re: 16 Channel GPIO Input Expander

Richard-TX wrote:I think it would be a lot easier to use a MCP233017 plus it would only occupy 2 GPIO pins leaving the rest for other things.
That's another possibility, Richard. I was just presenting a circuit idea.
by SavagePi
Tue May 27, 2014 6:14 pm
Forum: Other projects
Topic: 16 Channel GPIO Input Expander
Replies: 26
Views: 3131

Re: 16 Channel GPIO Input Expander

Hi, Where would you impliment this single resistor? Place the single resistor as pull-up resistor (value like 4k7 to 10k) on the chip's output pin (which is directly connected to GPIO input pin). 16 switches are connected towards ground. Best wishes, Ivan Zilic. That's not good practice with any CM...
by SavagePi
Tue May 27, 2014 5:41 pm
Forum: Other projects
Topic: 16 Channel GPIO Input Expander
Replies: 26
Views: 3131

Re: 16 Channel GPIO Input Expander

I understand all your points, Ivan. But that was not the object of my project. It was intended to explain various aspects of electronics design using CMOS IC's. I disagree with your use of positive voltage as a pull-up reference, since positive supplies can vary, whereas 0V is absolute in all circui...
by SavagePi
Tue May 27, 2014 4:30 pm
Forum: Other projects
Topic: 16 Channel GPIO Input Expander
Replies: 26
Views: 3131

Re: 16 Channel GPIO Input Expander

Okay. I've converted it to PDF.

Does this work...?

http://www.carol-anne-dolls.co.uk/Raspb ... pander.pdf
by SavagePi
Tue May 27, 2014 4:18 pm
Forum: Other projects
Topic: 16 Channel GPIO Input Expander
Replies: 26
Views: 3131

Re: 16 Channel GPIO Input Expander

Oh, the picture's been screwed up. It shouldn't be that tiny! It looks okay to me - but I'm using prosilver; others may see it differently Will this work I wonder... ? http://www.carol-anne-dolls.co.uk/Raspberry%20Pi%20GPIO%20Input%20Port%20Expander.doc No it didn't - at least for me! It wanted to ...
by SavagePi
Tue May 27, 2014 2:31 pm
Forum: Other projects
Topic: 16 Channel GPIO Input Expander
Replies: 26
Views: 3131

Re: 16 Channel GPIO Input Expander

Oh, the picture's been screwed up. It shouldn't be that tiny!

Will this work I wonder... ?

http://www.carol-anne-dolls.co.uk/Raspb ... pander.doc
by SavagePi
Tue May 27, 2014 2:29 pm
Forum: Other projects
Topic: 16 Channel GPIO Input Expander
Replies: 26
Views: 3131

16 Channel GPIO Input Expander

Here's a 'simple' design to allow 16 digital inputs using just 5 of the GPIO ports. CD4067B Schematic(2).gif And here's the code... # ************************************************ # * SAMPLE PROGRAM FOR USING THE CD4067B IC AS A * # * GPIO INPUT PORT EXPANDER. THIS PROVIDES 16 * # * DIGITAL INPUT...
by SavagePi
Sun May 25, 2014 7:57 pm
Forum: Automation, sensing and robotics
Topic: Problems with the HC-SR04 Ultrasonic Sensor
Replies: 15
Views: 16642

Re: Problems with the HC-SR04 Ultrasonic Sensor

The manufacturers recommendation is not to re-sample until 64mS later. But, since our programs are usually processing the data afterwards and doing other things in response to the results, 50mS using the (time.sleep) module is more than enough time before re-sampling.
by SavagePi
Sun May 25, 2014 7:44 pm
Forum: Automation, sensing and robotics
Topic: My Pi Car is complete (beginner)
Replies: 0
Views: 884

My Pi Car is complete (beginner)

After many weeks of experimenting and lots of help from various members on here, my Pi Car project is now complete. https://www.youtube.com/watch?v=-BVKxMV-frU Time to move on to my next project. Thank you to everyone who helped me (you know who you are ;-)) My final program... # *******************...
by SavagePi
Tue May 20, 2014 6:37 pm
Forum: Automation, sensing and robotics
Topic: Problems with the HC-SR04 Ultrasonic Sensor
Replies: 15
Views: 16642

Re: Problems with the HC-SR04 Ultrasonic Sensor

It's odd, I haven't seen that kind of scatter on the return of my HC-SR04 and Joan's graphs show that she didn't either (on a large sample size). Joan's graphs are perfect, Doug, and she's made an excellent effort in performing and describing her experiments. My findings are almost exactly the same...

Go to advanced search