Show Posts
|
|
Pages: [1] 2 3 ... 11
|
|
1
|
Development / Other Hardware Development / Re: Favorite I2C Digital Pot?
|
on: January 02, 2013, 12:56:40 pm
|
|
What I normally do is to look at the examples. I copy and paste parts that I need. Look at the Analog examples and the Serial examples. You will have to scale your setting according to the value of the pot and the range that it represents in your circuit. The better way though is to use PWM (analogWrite(pin, value)) to a pin in stead of the pot. Look at the analogWrite examples in the libraries and use pin 13 on the UNO. The LED is coupled there.
|
|
|
|
|
2
|
Development / Other Hardware Development / Re: Favorite I2C Digital Pot?
|
on: January 02, 2013, 09:37:14 am
|
You included the header file in your sketch instead of the code file. I included the header so that you can see how the chip was wired and to better understand the code. My code has many other files and was not done in the Arduino IDE but rather with a makefile. This will compile. Please look at the comments for connection data. Also look at the spec sheet of the chip. There are only three signals in all. NOTE: I did not initialize the pins in this sketch, you must do it in the setup section. #include "Arduino.h" // POT #define POT_SELECT 6 // connect the pot_cs of the chip to this pin #define INC 1 // connect the clk of the chip to this pin #define UD 5 // connect the direction pin of the chip to this pin // Pot #define UP 1 #define DOWN 0 #define SELECT 0 #define UN_SELECT 1 #define uint unsigned int
void setPot (uint requestedSpeed) { char val[2]; //calcPulses(val,config.motorSpeed, requestedSpeed); digitalWrite(INC,HIGH); digitalWrite(POT_SELECT,SELECT); digitalWrite(UD,val[1]); for(char i=1;i<val[0];i++) { digitalWrite(INC, HIGH); // sets the pin on delayMicroseconds(5000); // pauses for 50 microseconds digitalWrite(INC, LOW); // sets the pin off delayMicroseconds(5000); // pauses for 50 microseconds } digitalWrite(INC,HIGH); digitalWrite(POT_SELECT,HIGH); delay(20); }
void resetPot (void) { pinMode(INC,OUTPUT); pinMode(POT_SELECT,OUTPUT); pinMode(UD,OUTPUT); digitalWrite(INC,HIGH); digitalWrite(POT_SELECT,SELECT); digitalWrite(UD,DOWN); for(char i=0;i<100;i++) { digitalWrite(INC, HIGH); // sets the pin on delayMicroseconds(5000); // pauses for 50 microseconds digitalWrite(INC, LOW); // sets the pin off delayMicroseconds(5000); // pauses for 50 microseconds } digitalWrite(INC,HIGH); digitalWrite(POT_SELECT,HIGH); delay(20); }
void calcPulses (char val[],uint current, uint requested) { //char val[2]; char RpmPp = 550; //config.maxSpeed / 100; if(current < requested) { val[0] = (requested - current)/RpmPp; val[1] = UP; //return (*val); }else if(current > requested) { val[0] = (current - requested)/RpmPp; val[1] = DOWN; //return (*val); }else { //return (0); } } void setup(void) {
} void loop(void) { }
|
|
|
|
|
3
|
Development / Other Hardware Development / Re: Favorite I2C Digital Pot?
|
on: January 02, 2013, 06:08:07 am
|
I have this in the header file /** * @file x9cxx.h * @brief digital pot functions */ #ifndef x9cxx_H #define x9cxx_H // POT PINS #define POT_SELECT 6 #define INC 1 #define UD 5 // Pot FUNCTIONS #define UP 1 #define DOWN 0 #define SELECT 0 #define UNSELECT 1 void setPot (uint requestedSpeed); void resetPot (void); void calcPulses (char val[],uint current, uint requested);
#endif // #ifndef x9cxx_H
And this bit is the code I used. Not all the variables are define in this piece of code but yoy should be able to see how it is done. Very easy really. void setPot (uint requestedSpeed) { char val[2]; calcPulses(val,config.motorSpeed, requestedSpeed); digitalWrite(INC,HIGH); digitalWrite(POT_SELECT,SELECT); digitalWrite(UD,val[1]); for(char i=1;i<val[0];i++) { digitalWrite(INC, HIGH); // sets the pin on delayMicroseconds(5000); // pauses for 50 microseconds digitalWrite(INC, LOW); // sets the pin off delayMicroseconds(5000); // pauses for 50 microseconds } digitalWrite(INC,HIGH); digitalWrite(POT_SELECT,HIGH); delay(20); }
void resetPot (void) { pinMode(INC,OUTPUT); pinMode(POT_SELECT,OUTPUT); pinMode(UD,OUTPUT); digitalWrite(INC,HIGH); digitalWrite(POT_SELECT,SELECT); digitalWrite(UD,DOWN); for(char i=0;i<100;i++) { digitalWrite(INC, HIGH); // sets the pin on delayMicroseconds(5000); // pauses for 50 microseconds digitalWrite(INC, LOW); // sets the pin off delayMicroseconds(5000); // pauses for 50 microseconds } digitalWrite(INC,HIGH); digitalWrite(POT_SELECT,HIGH); delay(20); }
void calcPulses (char val[],uint current, uint requested) { //char val[2]; char RpmPp = config.maxSpeed / 100; if(current < requested) { val[0] = (requested - current)/RpmPp; val[1] = UP; }else if(current > requested) { val[0] = (current - requested)/RpmPp; val[1] = DOWN; } }
|
|
|
|
|
4
|
Using Arduino / Programming Questions / Core - built-in functions
|
on: August 08, 2012, 05:40:29 am
|
|
Hi all, Does anybody know of a document that explains or lists the core built-in functions. Things like the stream.h and print etc. I would like to see what is available as I find myself writing stuff to later find it in the core files somewhere.
|
|
|
|
|
7
|
Using Arduino / Installation & Troubleshooting / Re: Compile error with Mega2560 selected
|
on: June 15, 2012, 12:42:56 am
|
Mellis, It worked fine on Arduino0022. I just recently switched to Arduino1.0 as I was finishing up some projects and did not want to change midstream. The problem started with working code (from 0022) that was moved to Arduino1.0. It would seem that the Arduino1.0 core files are not all as up to date with your fixes.
|
|
|
|
|
9
|
Using Arduino / Installation & Troubleshooting / Compile error with Mega2560 selected
|
on: June 14, 2012, 03:06:45 am
|
Hi, I am using Arduino1.0. All works fine when I select any 328 board but when I try to compile for the Mega2560, I get string of errors from the core that I cant find the reason for. This is some of them In file included from C:\arduino-1.0\hardware\arduino\cores\arduino\/Platform.h:7, from C:\arduino-1.0\hardware\arduino\cores\arduino\CDC.cpp:19: c:/arduino-1.0/hardware/tools/avr/lib/gcc/../../avr/include/avr/eeprom.h: In function 'void eeprom_read_block(void*, const void*, size_t)': c:/arduino-1.0/hardware/tools/avr/lib/gcc/../../avr/include/avr/eeprom.h:290: error: ISO C++ forbids incrementing a pointer of type 'void*' c:/arduino-1.0/hardware/tools/avr/lib/gcc/../../avr/include/avr/eeprom.h:290: error: ISO C++ forbids incrementing a pointer of type 'const void*' c:/arduino-1.0/hardware/tools/avr/lib/gcc/../../avr/include/avr/eeprom.h:290: error: invalid conversion from 'const void*' to 'const uint8_t*' c:/arduino-1.0/hardware/tools/avr/lib/gcc/../../avr/include/avr/eeprom.h:290: error: initializing argument 1 of 'uint8_t eeprom_read_byte(const uint8_t*)' c:/arduino-1.0/hardware/tools/avr/lib/gcc/../../avr/include/avr/eeprom.h: In function 'void eeprom_write_block(const void*, void*, size_t)': c:/arduino-1.0/hardware/tools/avr/lib/gcc/../../avr/include/avr/eeprom.h:398: error: ISO C++ forbids incrementing a pointer of type 'void*' c:/arduino-1.0/hardware/tools/avr/lib/gcc/../../avr/include/avr/eeprom.h:398: error: ISO C++ forbids incrementing a pointer of type 'const void*' c:/arduino-1.0/hardware/tools/avr/lib/gcc/../../avr/include/avr/eeprom.h:398: error: invalid conversion from 'void*' to 'uint8_t*' c:/arduino-1.0/hardware/tools/avr/lib/gcc/../../avr/include/avr/eeprom.h:398: error: initializing argument 1 of 'void eeprom_write_byte(uint8_t*, uint8_t)'
|
|
|
|
|
12
|
Using Arduino / Installation & Troubleshooting / Uno boatloader and Avrdude
|
on: May 31, 2012, 12:59:21 am
|
|
Hi all I am trying to get Avrdude to talk to the boatloader on the Uno with these lines in my makefile
DEVICE = atmega328p PROGRAMMER = -c stk500 -P com38 AVRDUDE = avrdude $(PROGRAMMER) -p $(DEVICE) -B 10 -F
I get a continues timeout. What am I doing wrong or is this not possible?
|
|
|
|
|
14
|
Using Arduino / Installation & Troubleshooting / Re: No life after Uno R3
|
on: May 15, 2012, 03:18:36 am
|
Nick, I almost feel that you think I am telling lies.   Here I have the Deumilanove on Com31 and the Uno on Com38. The ISP is on Com35 and Com37. Sorry I can't capture the menu option in Arduino IDE but I promise they are all there.
|
|
|
|
|
15
|
Using Arduino / Installation & Troubleshooting / Re: No life after Uno R3
|
on: May 14, 2012, 11:51:29 am
|
Louis They show in the list but I get the avrdude: stk500_getsync(): not in sync: resp=0x00 error. When I say "does not see" I mean does not communicate. This happens for the programmer as well as the boatloader. I have been able to get the Uno R3 to program via the bootloader that it comes with but only under Arduino1.0. Arduino-1.0 also does not see any of the AvrIsp programmers Arduino-0022 does not see anything at the moment.
|
|
|
|
|