Int revSwitch = 12 // Digital input from Reverse SwitchĬonst int forwardSwitch = 9 // Output Pin for Speed Control (#15 of Kelly Controller)Ĭonst int reverseSwitch = 10 // Output Pin for Speed Control (#14)Ĭonst int brakeSwitch = 11 // Output Pin for Speed Control (#13)Ĭonst int slaveSelectPin = 53 // Slave Select PinĬonst byte REG0=B00000000 //Register 0 Write commandĬonst byte REG1=B00010000 //Register 1 Write commandįorwardAndReverse.attach(45) // pin for forward & reverse servo on Digipotīraking.attach(46) // pin for braking servo on Digipot Int Pot = A1 // Analog Input Pot from accl pedal to Arduino (split 50% forward + 50% reverse) It is to drive a speed controller for a robot. I’m using a digital pot (the same as in your book but only 1) and I want to feed the PWM signal from the code to the digital pot. loop through levels (start at 50 because <50 not perceptible one difference is that MCP42010 wants bytes instead of ints and needs for(int i=0 i <=2 i++) –original per Jeremy loop through registers (using 1-3 which rep as 0-2) argument for reg is byte for MCP42010 set to 17 or 18 mcp42010.init_MCP42xxx (Slave, SHDN, RS) //initialisation I assume this specifies which pot–dual or single (MCP4101) discovered define command (defines constants By Default, 11 = MOSI, 12 = MISO, 13 = CLK However, I did learn what my problem was: I was sending the wrong value for POT (different from AD5204). Out the include for the library and the references. Next step: find out what all that pin 8/9 for RS and SHDN was about. Learned that int works fine for level, and passed byte 17 (00010001) and 18 (00010010) in the for/next loop. * OK, above works, but I want to know why.įirst step is to see if I can get Jeremy’s setLed routine to work by changingĪrguments to bytes and using different values for command byte (B00010001 and B00010010 for pots 0 and 1). The example had them on pins 8 and 9 and uses the init_MCP42xxx routine One difference–I had the RS and SHDN pins going * I could not Jeremy’s example to work with the MCP42010. OrderedĢ duals instead (MCP42010),first step is do two LEDs, then we’ll try modify code for daisy-chaining. * Jeremy’s quad POT was not available as a DIP. SPI using digital POT to contol 3 LEDs Hope you can hellp me, especially on the SPI usage. Others talk about a LM317 (which has a too big Drop Out) or rather a LM 3940 but I am still not sure if this is necessary at all. Some use 2x 1N4007 diodes between 5vOut and 3.3vIn but I am not quite sure if this is necessary or not. Do you think I can try the 3.3v output of the MEGA anyways (though only gives up to 40 mA)? Instead, can I use the 5v Output without a voltage converter? As I read the ENC board is 5v tolerant. The ENC requires 3.3v with (as I heard and read) about 250mA. SO thats why Id like to ask you whethter you can help me on this one with a few ideas to solve the double SPI usage for these specific devices on a MEGA board. The problem I see is that the TLC doesnt use SC which (I think) means that the TLC will always be called and I cannot call the ENC.Īnyways, I am not a pro at all, I got most of my knowledge out of forums and tutorials. I know that the MEGA uses different PINs for SDI than the smaller brothers, thats not the prob. Now I would like to add the Ethernet ENC28J60 Breakout Shield which also uses SPI: I was wondering if maybe you as a pro could help me with this one:
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |