Go Down

Topic: MCP41100 byte address = 0x11; (Read 1 time) previous topic - next topic

1Ghasthunter1

Hello.
I am currently using an MCP41100 digipot in a circuit and I am having some trouble switch the signal pins. Currently, I have pins as so: CS - D10, SCLK - 13, and DI to 11. I want to switch it over to a smaller board which has D pins only up until D12. I tried to hook it up to that and realized it wouldn't work because of the piece of code:
Code: [Select]
byte address=0x11;. I know that in ASCII 0x11 = 17. I also know(from the oscilloscope) that the code
Code: [Select]
byte address=0x11; is what tells the arduino that my pins are on 11 and 13.(the CS pin is defined in the next line). Can anyone tell me what I need to have for so that my arduino can have SCLK on 12 and DI on 11?(I use the code from an  online example).
Code: [Select]

/*
this program taken from arduino Example .
  modified by By Mohannad Rawashdeh
  http://www.genotronex.com
  This code used to control the digital potentiometer
  MCP41100 connected to  arduino Board
  CS >>> D10
  SCLK >> D12
  DI  >>> D11
  PA0 TO VCC
  PBO TO GND
  PW0 TO led with resistor 100ohm .
*/
#include <SPI.h>
byte address=0x11;
int CS= 10;

void setup()
{
  pinMode (CS, OUTPUT);
  SPI.begin();
  // adjust high and low resistance of potentiometer
  // adjust Highest Resistance .
   digitalPotWrite(0x00);
   delay(1000);
 
      // adjust  wiper in the  Mid point  .
   digitalPotWrite(0x80);
   delay(1000);

   // adjust Lowest Resistance .
   digitalPotWrite(0xFF);
   delay(1000);
}

void loop()
{
    for (int i = 0; i <= 255; i++)
    {
      digitalPotWrite(i);
      delay(10);
    }
    delay(1000);
    for (int i = 255; i >= 0; i--)
    {
      digitalPotWrite(i);
      delay(5);
    }
   
}

int digitalPotWrite(int value)
{
  digitalWrite(CS, LOW);
  SPI.transfer(address);
  SPI.transfer(value);
  digitalWrite(CS, HIGH);
}



Jiggy-Ninja

What smaller board? There should be a D13 on there somewhere, unless it's a different architecture. There are a lot of different boards that can be programmed with Arduino these days, be specific.

If it's an AVR-based board, you can't reassign the peripheral pins willy-nilly. They are locked in their locations. Fortunately, if you must relocate the pins, you can just use the shiftOut funtion instead of the SPI library.
I tried to hook it up to that and realized it wouldn't work because of the piece of code:
Code: [Select]
byte address=0x11;
. I know that in ASCII 0x11 = 17. I also know(from the oscilloscope) that the code
Code: [Select]
byte address=0x11;
 is what tells the arduino that my pins are on 11 and 13.(the CS pin is defined in the next line).
No it does not. That variable does nothing to the Arduino's SPI setup. It isn't even an address. It is the command byte sent to the digipot which tells it that you will be writing a value to potentiometer 0.

Datasheet, page 18.
Hackaday: https://hackaday.io/MarkRD
Advanced C++ Techniques: https://forum.arduino.cc/index.php?topic=493075.0

1Ghasthunter1

First Of All, In ASCII 0x11 is equal to 17, but that is not what i am trying to prove. For the boards, It works on an arduino UNO as it has a D13 pin, but I am using an arduino nano(kookye) which only has up to D12

Jiggy-Ninja

#3
Apr 25, 2017, 04:52 pm Last Edit: Apr 25, 2017, 04:53 pm by Jiggy-Ninja
Quote
First Of All, In ASCII 0x11 is equal to 17, but that is not what i am trying to prove.
What does that have to do with anything? First of all, it's wrong because ASCII is something completely different. Second, it's irrelevant. I know how to convert numbers to a different radix, that's got nothing to do with the actual function that number has in the code. It doesn't matter whether you type 17, 0x11, B10001, or 021, it won't change anything.

Read what I wrote in the last post. I told you exactly what the function of the 0x11 is. If you don't understand it, ask more questions.

Quote
For the boards, It works on an arduino UNO as it has a D13 pin, but I am using an arduino nano(kookye) which only has up to D12
Check on the other edge of the board.
Hackaday: https://hackaday.io/MarkRD
Advanced C++ Techniques: https://forum.arduino.cc/index.php?topic=493075.0

1Ghasthunter1

well ok that solves alot of problems. sure enough on the other side of the board the one and only D13 pin on the nano. Thanks for the help

Go Up