Saturday, September 24, 2022

Coffee Saturdays. Bus Pirate, MCP4725, and Scuttlebutts

  I miss working on projects in the coffee shop, so I wandered to Scuttlebutts in the Clayworks with a bus pirate, a DAC and a laptop to play around with the DAC and maybe learn something. I'm resurecting the blog because I have too many projects and I don't feel like I get anything done, but I don't have anywhere that is tracking overall progress. So if I write about what I'm doing right now, then perhaps I won't feel so bad.

or perhaps I'll feel worse. Let's see what happens.

I hadn't touched the bus pirate in awhile so some if this is just getting reacquainted with it and maybe learning some new things. I have specific end goals in mind but let's not distract ourselves more than we already are. The bus pirate is a neat tool. Whenever I excitedly babble about it people are just like "an Arduino does that" they are kind of right. An arduino can do all the things a bus pirate does with some code and a circuit. But the bus pirate is a dedicated interpreter of protocols that is already programmed. If you learn the bus pirate you can tie into a problem bus and learn what's going on very quickly. It also has various pwm and dac functions that... yes the arduino has... but are already programmed in. Think of it as a simplistic C3P0 you can use to diag your hyperdrive.

so here is a screenshot of my pirate, it's an older model but it does what I need. Today I mostly just fired it up and connected to it to clear out some cobwebs in my brain. 

On Windows 10 I plug it in and grep device manager and look at what com port it's on. Then I putty into it at 115200 Serial. Screen is always empty when I connect but if you hit enter it will say HiZ>. The bus pirate is nice enough to always start in HiZ mode to avoid breaking whatever it's connected to. so when your done using it you don't have to disconnect anything you can just toss it all in a box for later. Mine lives in a sparkfun box, probably because it came in a sparkfun box. 

So the DAC is an MCP4725 which is a 12 bit DAC that claims it's I2C. Actually, its a module from sparkfun. So there is header pins and whatnot. So we hit m and 4 and it asks us to set the speed. In the datasheet "fast" is 400kbps and there is a ~400KHz so let's see if we can give that an old spinaroo. The mode light on the bus pirate is lit. 

So Ground is tied to ground. Going from Dac to pirate - VCC is tied to 5v (max voltage is 5.5 on the DAC) SDA is tied to CS, SCL is tied to Clk GND is tied to MISO, and out is tied to ADC. 

in 8.1 we find out that SDA and SCL are open drain. So it either does or doesn't sink current. We handle this with pullup resistors ( P ). BUT there is no voltage on Vpullup pin. so we need to W and turn on the power supply unit. Now I have four red lights on the pirate. nothing seems warm, and v Shows me that the 3.3V looks good, the 5v looks good, the ADC is sitting at 2.48 which is halfway between 5v and 0V Aux is low (We aren't connected to it) SCL and SDA are both HI and we don't care about the rest. So not only is the device powered on, but the device is happily sourcing 2.5V and the pirate is reading it and they are all happy.

7.1 says that the device code is 1100. the address bits according to Sparkfun's hookup guide are 0x60 so BUT we want to know for sure, so we check to see what macros we have (0) there is (1)  7 bit address search, and (2) I2C sniffer. (1) found read and write at address 0x62 So that is prob the address for my device. It's 10:00 and I should probably get home. BUT we are talking to and reading the output of the DAC with the bus pirate. So that doesn't suck.

No comments:

Post a Comment