electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
 Forum index » DIY Hardware and Software » Lunettas - circuits inspired by Stanley Lunetta
Gating oscillators with microcontrollers
Post new topic   Reply to topic Moderators: mosc
Page 1 of 1 [8 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
cerkit



Joined: Nov 17, 2016
Posts: 17
Location: Montgomery, AL USA

PostPosted: Mon Feb 06, 2017 9:20 am    Post subject: Gating oscillators with microcontrollers
Subject description: Feedback requested
Reply with quote  Mark this post and the followings unread

I think I have discovered the answer I was looking for in my previous post. I have ordered a lot more parts since then and had what I needed to make this happen.

My goal was to be able to easily gate the output of a 40106 oscillator using a micro controller. My first attempt (incorrectly) utilized a NAND gate and directly connected the output of the 40106 and the GPIO Pin of a Raspberry Pi to the gate. This was an error because I was running the Lunetta at 5v and the output voltage of the Raspberry Pi GPIO pins is 3.3v (not to mention I was using a NAND gate - it "worked", but I got the reverse of what I was expecting).

After searching around, I discovered the MCP23017 I²C I/O port expander. It runs at 5v and can easily communicate with the Raspberry Pi over I²C. It has 16 pins that can be used as input or output.

I have attached the schematic of my circuit in the hopes that I can get some peer review.

I was able to successfully get this working, but I'd like to know if anyone sees anything that might be amiss.

I also have a blog entry that goes into greater detail about my process and the end result. I am using Windows 10 IoT as my OS on the Raspberry Pi, but this works with any micro controller that can communicate via I²C (there is also an SPI version of the I/O port expander available).

Controlling a 40106 Oscillator - Part 2

I would appreciate any input or constructive criticism you can provide. I'm very new to this and I'm still learning how to use Eagle. I'm not entirely sure how to wire up the Raspberry Pi header outputs so that the board transfer will look right.

Thanks for your time.


Completed40103OscillatorANDGateWithMCP23017.png
 Description:
This is the schematic for the 40106 Oscillator gate circuit utilizing a MCP231017 I²C I/O port expander.
 Filesize:  70.55 KB
 Viewed:  401 Time(s)
This image has been reduced to fit the page. Click on it to enlarge.

Completed40103OscillatorANDGateWithMCP23017.png


Back to top
View user's profile Send private message
gdavis



Joined: Feb 27, 2013
Posts: 359
Location: San Diego
Audio files: 1

PostPosted: Tue Feb 07, 2017 6:27 pm    Post subject: Reply with quote  Mark this post and the followings unread

Well, you still have the same issue of driving a chip running at 5V with a 3.3V logic signal. The 23017 doesn't resolve that any more than a nand gate does. It's great for adding more I/O's if you need them, but it's not a level shifter.

You also don't need all those 100k resistors. Just connect unused inputs to ground and you can leave unused outputs unconnected.

_________________
My synth build blog: http://gndsynth.blogspot.com/
Back to top
View user's profile Send private message
cerkit



Joined: Nov 17, 2016
Posts: 17
Location: Montgomery, AL USA

PostPosted: Tue Feb 07, 2017 6:53 pm    Post subject: Reply with quote  Mark this post and the followings unread

gdavis wrote:
Well, you still have the same issue of driving a chip running at 5V with a 3.3V logic signal. The 23017 doesn't resolve that any more than a nand gate does. It's great for adding more I/O's if you need them, but it's not a level shifter.

You also don't need all those 100k resistors. Just connect unused inputs to ground and you can leave unused outputs unconnected.


I'm confused, it seems to be handling the I²C messages like it should.

Upon further research, I have found a blog post about this very issue as it relates to the Raspberry Pi and why my circuit is working, even though it is out of spec.

Raspberry Pi and I2C devices of different voltage

I will most likely create an I²C level shifter circuit specifically for my future endeavors. I will need the GPIO pins on the Raspberry Pi for other applications. This way, I only need a single level shifter for the I²C that can help me control the expanded ports.

Thanks for the tip about removing the resistors. I wish I could find the original source that recommended using 100k resistors on unused pins. This will save me from all of this resistor madness (and make my schematics a lot more tame).
Back to top
View user's profile Send private message
gdavis



Joined: Feb 27, 2013
Posts: 359
Location: San Diego
Audio files: 1

PostPosted: Tue Feb 07, 2017 7:35 pm    Post subject: Reply with quote  Mark this post and the followings unread

cerkit wrote:
gdavis wrote:
Well, you still have the same issue of driving a chip running at 5V with a 3.3V logic signal. The 23017 doesn't resolve that any more than a nand gate does. It's great for adding more I/O's if you need them, but it's not a level shifter.

You also don't need all those 100k resistors. Just connect unused inputs to ground and you can leave unused outputs unconnected.


I'm confused, it seems to be handling the I²C messages like it should.

It's called luck. Electronics aren't black and white. Just because something appears to be working now doesn't mean it will be reliable. Change in temperature or use a part from another batch and you may suddenly start to see errors.

Basically what happens is you have two transistors on the input - one registers a high and the other registers a low. When you're "in between", those two transistors are fighting with each other with no guarantee over which one will win out. Also, they will both be conducting abnormally large amounts of current for extended periods of time. In normal operation the transition between low and high is very short so the current during the in between part isn't a concern, but when you constantly drive it at the incorrect level it can cause cumulative damage leading to premature failure.

Quote:
Upon further research, I have found a blog post about this very issue as it relates to the Raspberry Pi and why my circuit is working, even though it is out of spec.

Raspberry Pi and I2C devices of different voltage

I will most likely create an I²C level shifter circuit specifically for my future endeavors. I will need the GPIO pins on the Raspberry Pi for other applications. This way, I only need a single level shifter for the I²C that can help me control the expanded ports.

That web page has a nice circuit for the I2C level shifting. You wouldn't need the resistors on the Raspberry side (the board already has them) so you'd just need the two transistors and two resistors for the 5V side. Definitely nice that you only have to shift the two I2C signals to get 16 I/O's.

Quote:
Thanks for the tip about removing the resistors. I wish I could find the original source that recommended using 100k resistors on unused pins. This will save me from all of this resistor madness (and make my schematics a lot more tame).

Not sure why anyone would suggest that except maybe to save you from accidentally connecting an output to ground. They don't hurt but it's a lot of unnecessary components cluttering the board.

_________________
My synth build blog: http://gndsynth.blogspot.com/
Back to top
View user's profile Send private message
cerkit



Joined: Nov 17, 2016
Posts: 17
Location: Montgomery, AL USA

PostPosted: Thu Feb 09, 2017 7:12 am    Post subject: Reply with quote  Mark this post and the followings unread

gdavis wrote:
That web page has a nice circuit for the I2C level shifting. You wouldn't need the resistors on the Raspberry side (the board already has them) so you'd just need the two transistors and two resistors for the 5V side. Definitely nice that you only have to shift the two I2C signals to get 16 I/O's.


Do you think a single level shifter on the I2C interface will work if I add additional I2C components to the circuit? I may add additional MCP23017s or other I2C devices.
Back to top
View user's profile Send private message
gdavis



Joined: Feb 27, 2013
Posts: 359
Location: San Diego
Audio files: 1

PostPosted: Thu Feb 09, 2017 12:35 pm    Post subject: Reply with quote  Mark this post and the followings unread

cerkit wrote:
gdavis wrote:
That web page has a nice circuit for the I2C level shifting. You wouldn't need the resistors on the Raspberry side (the board already has them) so you'd just need the two transistors and two resistors for the 5V side. Definitely nice that you only have to shift the two I2C signals to get 16 I/O's.


Do you think a single level shifter on the I2C interface will work if I add additional I2C components to the circuit? I may add additional MCP23017s or other I2C devices.


Yes, that's the beauty of it! You can have any number of 3.3V devices on the 3.3V side and any number of 5V devices on the 5V side. That's what the "device" boxes at the bottom of the diagram are trying to show.

_________________
My synth build blog: http://gndsynth.blogspot.com/
Back to top
View user's profile Send private message
blue hell
Site Admin


Joined: Apr 03, 2004
Posts: 24079
Location: The Netherlands, Enschede
Audio files: 278
G2 patch files: 320

PostPosted: Thu Feb 09, 2017 1:10 pm    Post subject: Reply with quote  Mark this post and the followings unread

cerkit wrote:
[...] I may add additional MCP23017s or other I2C devices.


As stated above already, yes ... but ... note ... that you can not then tie the address bits A0 .. A2 all to ground for additional MCP23017s - they will need different addresses to be set.

_________________
Jan
also .. could someone please turn down the thermostat a bit.
Posted Image, might have been reduced in size. Click Image to view fullscreen.
Back to top
View user's profile Send private message Visit poster's website
cerkit



Joined: Nov 17, 2016
Posts: 17
Location: Montgomery, AL USA

PostPosted: Fri Feb 10, 2017 6:40 am    Post subject: Reply with quote  Mark this post and the followings unread

Blue Hell wrote:
cerkit wrote:
[...] I may add additional MCP23017s or other I2C devices.


As stated above already, yes ... but ... note ... that you can not then tie the address bits A0 .. A2 all to ground for additional MCP23017s - they will need different addresses to be set.


That's good information, thanks.

I'm very new to this, so this is all very helpful. Thanks for your time.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic Moderators: mosc
Page 1 of 1 [8 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
 Forum index » DIY Hardware and Software » Lunettas - circuits inspired by Stanley Lunetta
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003 through 2009 by electro-music.com - Conditions Of Use