Show Posts
|
|
Pages: [1] 2
|
|
1
|
Development / Other Software Development / Re: Decoupling shield libraries from the Arduino core
|
on: February 26, 2013, 02:09:42 pm
|
|
Well, just to resolve this for anybody who might attempt this in the future, I was able to just include several of the Arduino core files in my project in order to satisfy the dependencies on them, but the one dependency I had to remove was the HardwareSerial library, because that relied on the CDC code (at least for the Atmega32U4 that I'm working with), which in turn depended on the entire USB core, which was what I was trying to get away from in the first place. So the CLEAN solution would have been to re-implement the HardwareSerial interface (or at least the Serial_ class) using LUFA-compatible code, but 1)I didn't want a CDC interface in my device (though I suppose I could have implemented it via the UART instead of USB) and 2)I was lazy. So I ended up just commenting out all of the Serial.println()'s in the shield library... which removed all of the serial debugging, but oh well. Eventually, I'll probably just add a UART-based implementation of the Serial_ class and be done with it, but for now, it seems to be working...
|
|
|
|
|
2
|
Development / Other Software Development / Decoupling shield libraries from the Arduino core
|
on: February 12, 2013, 03:57:27 pm
|
|
I've been really interested in many of the LUFA hacks that have led to custom devices on the Arduino by re-flashing the Atmega16U2 on the Uno and Mega2560 boards. I'm in the process of building a project with USB MIDI output, and it works great on the Uno and Mega2560, using LUFA-based MIDI firmware on the 16U2, but I would really like to cut out the middle-man and target my project to the Leonardo, so the entire code base is running on a single microcontroller. The problem is, I'm using the Circuits@Home USB host shield, and their libraries are coupled to the Arduino core, whereas I would rather utilize the LUFA build system, which allows me complete control of the USB device descriptors, allowing me to create any kind of device I want (which is why LUFA has been the go-to library for those sorts of hacks). So my question is, has anybody here had any experience decoupling shield libraries from the Arduino core? Or maybe the answer is to go a different route, and link the two code libraries... but I have a feeling that wouldn't work, due to my requirement for being able to control the device descriptors via the LUFA build system, where I'm pretty sure the Arduino core handles that itself. I would really like to end up with a truly plug-and-play device, acting as a pure generic USB MIDI controller. So there is my dilemma. On the one hand, I have the LUFA code doing what I want it to do as far as the PC interface side of things, but on the other hand, I need the USB Host Shield library in order to communicate with the external devices I'm using to actually control the MIDI device. Any suggestions?
|
|
|
|
|
4
|
Using Arduino / Networking, Protocols, and Devices / Leonardo HID Gamepad
|
on: November 08, 2012, 01:33:38 am
|
I'm trying to implement an HID gamepad on the Leonardo. I've already added the following to the device descriptor in HID.cpp (4 buttons, 2 axes): // Gamepad 0x05, 0x01, // USAGE_PAGE (Generic Desktop) 0x09, 0x05, // USAGE (Game Pad) 0xa1, 0x01, // COLLECTION (Application) 0xa1, 0x00, // COLLECTION (Physical) 0x85, 0x03, // REPORT_ID (3) 0x05, 0x09, // USAGE_PAGE (Button) 0x19, 0x01, // USAGE_MINIMUM (Button 1) 0x29, 0x08, // USAGE_MAXIMUM (Button 8) 0x15, 0x00, // LOGICAL_MINIMUM (0) 0x25, 0x01, // LOGICAL_MAXIMUM (1) 0x95, 0x04, // REPORT_COUNT (4) 0x75, 0x01, // REPORT_SIZE (1) 0x81, 0x02, // INPUT (Data,Var,Abs) 0x05, 0x01, // USAGE_PAGE (Generic Desktop) 0x09, 0x30, // USAGE (X) 0x09, 0x31, // USAGE (Y) 0x15, 0xff, // LOGICAL_MINIMUM (-1) 0x25, 0x01, // LOGICAL_MAXIMUM (1) 0x95, 0x02, // REPORT_COUNT (2) 0x75, 0x02, // REPORT_SIZE (2) 0x81, 0x02, // INPUT (Data,Var,Abs) 0xc0, // END_COLLECTION 0xc0 // END_COLLECTION
I've also added the following class declaration to USBAPI.h: class Gamepad_ { private: uint8_t _buttons; public: Gamepad_(void); void begin(void); void end(void); void press(uint8_t b); void release(uint8_t b); bool isPressed(uint8_t b); }; extern Gamepad_ Gamepad;
However, when I try to call any of the Gamepad functions (Gamepad.begin(), Gamepad.press(), etc.), it throws an undefined reference to Gamepad. So apparently, I'm missing something. Can anybody with knowledge of the Arduino HID implementation help point me in the right direction? If I comment out any calls to the Gamepad class, I can compile it and upload the sketch, and it shows up as a gamepad in Windows with 2 axes and 4 buttons, so the device descriptor is good. I'm just missing a reference to my newly defined class. Any ideas?
|
|
|
|
|
5
|
Using Arduino / Networking, Protocols, and Devices / First time with the Ethernet shield
|
on: May 20, 2012, 08:14:27 pm
|
I'm currently trying to use my Arduino with an Ethernet shield to act as a simulator for a networked device in my university Junior Project. We're currently running the simulation on a laptop, but just for kicks, I wanted to try to make it work on the Arduino. Basically, we're writing an iPad app capable of communicating with a vehicle over a network for diagnostics and such, and the Arduino is going to simulate the vehicle side of things. Basically it's running as a server, receiving commands from the iPad, and shipping out data packets at regular intervals describing the current state of the vehicle (gas/battery levels, rpm, speed, etc.). Currently, I have the iPad able to establish a connection with the Arduino and recognize that it receives at least the initial data packet (I have not yet added the code for simulating changes in the data like gas/battery levels decreasing over time, change in speed, etc.), but at some point, it just freezes up. I didn't write the iPad code (other members of my team were responsible for that), but here is my current Arduino code. It's my first time doing networking with the Arduino, so I'm sure I just messed up something simple. Also, the use of a statically allocated struct and memcpy for my payload is a hack, I know, but the I couldn't find any decent method of serializing the data, and the String class is useless, so it's the least of the evils I could devise, and according to Wireshark, it's working, so that's good enough for me. I have a momentary pushbutton between pin 52 and GND, and for now it's just toggling a single value so I can see if it's working or not (it isn't. pushing the button freezes the Arduino until I release it, and if I hold it too long it never resumes). Any help is greatly appreciated. #include <SPI.h> #include <Ethernet.h> #include <EthernetUdp.h> #include <TimerOne.h>
#define CLOCK 1000000
// Define MAC address and destination port byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x92, 0xFB }; IPAddress broadcastIP; unsigned int localPort = 55555;
float fuel_level = 1.0; float battery_level = 1.0; int speed = 0; int electric_rpm = 0; int ic_rpm = 0; bool electric_on = 0; bool ic_on = 0; int battery_temp = 0;
/* <?xml version="1.0" encoding="UTF-8"?> <data> <fl>[info]</fl> <bl>[info]</bl> <sp>[info]</sp> <emr>[info]</emr> <icr>[info]</icr> <ti>[info]</ti> <emto>[info]</emto> <icto>[info]</icto> <bt>[info]</bt> <bs>[info]</bs> <ss>[info]</ss> </data>*/ struct { char t1[50]; char fl[8]; char t2[10]; char bl[8]; char t3[10]; char sp[8]; char t4[11]; char emr[8]; char t5[12]; char icr[8]; char t6[23]; char emto[1]; char t7[14]; char icto[1]; char t8[12]; char bt[8]; char t9[26]; } udpPayload;
char buffer[10];
EthernetUDP Udp; EthernetServer server = EthernetServer(localPort); EthernetClient client;
boolean connected = false;
void setup() { pinMode(13, OUTPUT); pinMode(52, INPUT); pinMode(53, OUTPUT); digitalWrite(52, HIGH); Ethernet.begin(mac); server.begin(); Udp.begin(localPort); Serial.begin(9600); delay(1000); // give the Ethernet shield a second to initialize: Serial.println("connecting..."); Serial.print("Local IP Address: "); Serial.println(Ethernet.localIP()); broadcastIP = Ethernet.localIP(); broadcastIP[3] = 255; memcpy(udpPayload.t1, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data>\n<fl>", 50); memcpy(udpPayload.t2, "</fl>\n<bl>", 10); memcpy(udpPayload.t3, "</bl>\n<sp>", 10); memcpy(udpPayload.t4, "</sp>\n<emr>", 11); memcpy(udpPayload.t5, "</emr>\n<icr>", 12); memcpy(udpPayload.t6, "</icr>\n<ti></ti>\n<emto>", 23); memcpy(udpPayload.t7, "</emto>\n<icto>", 14); memcpy(udpPayload.t8, "</icto>\n<bt>", 12); strcpy(udpPayload.t9, "</bt>\n<bs></bs>\n<ss></ss>"); Timer1.initialize(CLOCK); // Set up a timer at the defined resolution Timer1.attachInterrupt(tick); // Attach the tick function }
void loop() { // if an incoming client connects, there will be bytes available to read: client = server.available(); if (client) { if(!connected) { client.flush(); Serial.println("Connected to client."); connected = true; } // read bytes from the incoming client and write them back // to any clients connected to the server: while(client.available()) { char buf = client.read(); Serial.print(buf); } //Serial.println(""); client.stop(); battery_temp = digitalRead(52); } }
void tick() { updatePayload(); broadcastPayload(); }
void updatePayload() { dtostrf(fuel_level, 3, 6, buffer); memcpy(udpPayload.fl, buffer, 8); dtostrf(battery_level, 3, 6, buffer); memcpy(udpPayload.bl, buffer, 8); sprintf(buffer, "%8d", speed); memcpy(udpPayload.sp, buffer, 8); sprintf(buffer, "%8d", electric_rpm); memcpy(udpPayload.emr, buffer, 8); sprintf(buffer, "%8d", ic_rpm); memcpy(udpPayload.icr, buffer, 8); sprintf(buffer, "%1d", electric_on); memcpy(udpPayload.emto, buffer, 8); sprintf(buffer, "%1d", ic_on); memcpy(udpPayload.icto, buffer, 8); sprintf(buffer, "%8d", battery_temp); memcpy(udpPayload.bt, buffer, 8); }
void broadcastPayload() { Udp.beginPacket(broadcastIP, localPort); Udp.write((uint8_t *)&udpPayload, sizeof(udpPayload)); Udp.endPacket(); }
|
|
|
|
|
6
|
Using Arduino / Networking, Protocols, and Devices / Trying to convert project to use alternative USB<->RS232 UART chip
|
on: March 21, 2012, 06:57:35 pm
|
I'm in the process of building a project that I found online that uses an Atmega 8515 and an FTDI FT232BL USB<->RS232 UART converter. I'm wondering if it is possible to replace the FT232BL with the Texas Instruments TUSB3410 as a straight drop-in replacement, or what considerations will have to be made in switching the design from the one chip to the other. The reason I want to do this is simply because I have several of the TI chips laying around and I'd like to use what I have if at all possible. I understand that this is a question that is highly dependent on which functions of the chip I intend to utilize, as I can see that the chips do differ in features. However, it seems that the project I'm working with really just uses the bare minimum USB<->RS232 functionality on the chip, so I'm hoping that it can be done. The difficult part is that I don't have access to the code used to program the Atmega, so I'd need for the TUSB3410 to interface identically (but this shouldn't be an issue because USB and RS232 are both standardized protocols, so as long as I hook up to the right pins the operation should be identical, right? Or is it more complicated than that?). I realize this might not be a simple question to answer entirely, but any help at all pointing me in the right direction (or else a straight "not gonna happen") would be greatly appreciated. For reference, here's the schematic for the project I'm building: http://www.reinerziegler.de/GB-Flasher/schem+pcb/GB%20Cart%20Flasher%20(USB).pdfAnd here are the datasheets for the two chips: http://www.ftdichip.com/Support/Documents/DataSheets/ICs/DS_FT232BL_BQ.pdfhttp://www.ti.com/lit/gpn/tusb3410
|
|
|
|
|
8
|
Using Arduino / Microcontrollers / Re: ArduinoISP programming Atmega8515 on breadboard
|
on: March 13, 2012, 11:42:09 pm
|
Try the "arduino" protocol...
avrdude -p m8515 -P com7 -c arduino -v -v -v -b 19200 -U flash:w:gbcf-fw-2.1-usb.hex
Finally, some headway  Unfortunately, new errors  C:\>avrdude -p m8515 -P com7 -c arduino -v -v -v -b 19200 -U flash:w:gbcf-fw-2.1-usb.hex
avrdude: Version 5.10, compiled on Jan 19 2010 at 10:45:23 Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/ Copyright (c) 2007-2009 Joerg Wunsch
System wide configuration file is "C:\WinAVR-20100110\bin\avrdude.conf"
Using Port : com7 Using Programmer : arduino Overriding Baud Rate : 19200 AVR Part : ATMEGA8515 Chip Erase delay : 9000 us PAGEL : P00 BS2 : P00 RESET disposition : dedicated RETRY pulse : SCK serial program mode : yes parallel program mode : yes Timeout : 200 StabDelay : 100 CmdexeDelay : 25 SyncLoops : 32 ByteDelay : 0 PollIndex : 3 PollValue : 0x53 Memory Detail :
Block Poll Page Polled Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- --------- eeprom 4 10 128 0 no 512 0 0 9000 9000 0xff 0xff Block Poll Page Polled Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- --------- flash 33 6 64 0 yes 8192 64 128 4500 4500 0xff 0xff Block Poll Page Polled Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- --------- lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00 Block Poll Page Polled Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- --------- hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00 Block Poll Page Polled Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- --------- lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00 Block Poll Page Polled Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- --------- calibration 0 0 0 0 no 4 0 0 0 0 0x00 0x00 Block Poll Page Polled Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- --------- signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00
Programmer Type : Arduino Description : Arduino Hardware Version: 2 Firmware Version: 1.18 Topcard : Unknown Vtarget : 0.0 V Varef : 0.0 V Oscillator : Off SCK period : 0.1 us
avrdude: please define PAGEL and BS2 signals in the configuration file for part ATMEGA8515 avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.02s
avrdude: Device signature = 0x1e9306 avrdude: safemode read 1, lfuse value: e1 avrdude: safemode read 2, lfuse value: e1 avrdude: safemode read 3, lfuse value: e1 avrdude: safemode: lfuse reads as E1 avrdude: safemode read 1, hfuse value: d9 avrdude: safemode read 2, hfuse value: d9 avrdude: safemode read 3, hfuse value: d9 avrdude: safemode: hfuse reads as D9 avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option. avrdude: erasing chip avrdude: please define PAGEL and BS2 signals in the configuration file for part ATMEGA8515 avrdude: reading input file "gbcf-fw-2.1-usb.hex" avrdude: input file gbcf-fw-2.1-usb.hex auto detected as Intel Hex avrdude: writing flash (3614 bytes):
Writing | ################################################## | 100% 5.67s
avrdude: 3614 bytes of flash written avrdude: verifying flash memory against gbcf-fw-2.1-usb.hex: avrdude: load data flash data from input file gbcf-fw-2.1-usb.hex: avrdude: input file gbcf-fw-2.1-usb.hex auto detected as Intel Hex avrdude: input file gbcf-fw-2.1-usb.hex contains 3614 bytes avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 3.02s
avrdude: verifying ... avrdude: verification error, first mismatch at byte 0x0010 0x87 != 0x88 avrdude: verification error; content mismatch
avrdude: safemode read 1, lfuse value: e1 avrdude: safemode read 2, lfuse value: e1 avrdude: safemode read 3, lfuse value: e1 avrdude: safemode: lfuse reads as E1 avrdude: safemode read 1, hfuse value: d9 avrdude: safemode read 2, hfuse value: d9 avrdude: safemode read 3, hfuse value: d9 avrdude: safemode: hfuse reads as D9 avrdude: safemode: Fuses OK
avrdude done. Thank you.
|
|
|
|
|
9
|
Using Arduino / Microcontrollers / Re: ArduinoISP programming Atmega8515 on breadboard
|
on: March 13, 2012, 10:17:20 pm
|
I specified stk500 (not v2). Just for kicks, I tried them both: C:\>avrdude -p m8515 -P com7 -c stk500 -v -v -v -b 19200 -U flash:w:gbcf-fw-2.1-usb.hex
avrdude: Version 5.10, compiled on Jan 19 2010 at 10:45:23 Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/ Copyright (c) 2007-2009 Joerg Wunsch
System wide configuration file is "C:\WinAVR-20100110\bin\avrdude.conf"
Using Port : com7 Using Programmer : stk500 Overriding Baud Rate : 19200 avrdude: stk500_2_ReceiveMessage(): timeout C:\>avrdude -p m8515 -P com7 -c stk500v2 -v -v -v -b 19200 -U flash:w:gbcf-fw-2.1-usb.hex
avrdude: Version 5.10, compiled on Jan 19 2010 at 10:45:23 Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/ Copyright (c) 2007-2009 Joerg Wunsch
System wide configuration file is "C:\WinAVR-20100110\bin\avrdude.conf"
Using Port : com7 Using Programmer : stk500v2 Overriding Baud Rate : 19200 avrdude: stk500_2_ReceiveMessage(): timeout
|
|
|
|
|
10
|
Using Arduino / Microcontrollers / Re: ArduinoISP programming Atmega8515 on breadboard
|
on: March 13, 2012, 09:16:11 pm
|
Finally got the last of the parts, hooked it up, flashed the ArduinoISP sketch, fired up avrdude and got this: avrdude: stk500_2_ReceiveMessage(): timeout
[repeats the timeout message over and over for several minutes] Then after a few minutes this comes up: avrdude: stk500v2_getsync(): timeout communicating with programmer AVR Part : ATMEGA8515 Chip Erase delay : 9000 us PAGEL : P00 BS2 : P00 RESET disposition : dedicated RETRY pulse : SCK serial program mode : yes parallel program mode : yes Timeout : 200 StabDelay : 100 CmdexeDelay : 25 SyncLoops : 32 ByteDelay : 0 PollIndex : 3 PollValue : 0x53 Memory Detail :
Block Poll Page Polled Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- --------- eeprom 4 10 128 0 no 512 0 0 9000 9000 0xff 0xff Block Poll Page Polled Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- --------- flash 33 6 64 0 yes 8192 64 128 4500 4500 0xff 0xff Block Poll Page Polled Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- --------- lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00 Block Poll Page Polled Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- --------- hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00 Block Poll Page Polled Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- --------- lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00 Block Poll Page Polled Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- --------- calibration 0 0 0 0 no 4 0 0 0 0 0x00 0x00 Block Poll Page Polled Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- --------- signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00 Programmer Type : STK500V2 Description : Atmel STK500 Programmer Model: Unknown avrdude: stk500_2_ReceiveMessage(): timeout [continues repeating every few seconds] I get the same error with the TinyISP sketch that Coding Badly sent me.
|
|
|
|
|
11
|
Using Arduino / Microcontrollers / Re: ArduinoISP programming Atmega8515 on breadboard
|
on: March 12, 2012, 10:46:12 pm
|
Not correct. (Sorry I missed that in your earlier post.) The capacitor goes from RESET to GND (after uploading the ArduinoISP sketch).
When using a (120 ohm) resistor to disable auto-reset, the resistor is connected from RESET to +5V.
Woops, that's actually how I have it hooked up, I wasn't really paying attention when I typed 
|
|
|
|
|
12
|
Using Arduino / Microcontrollers / Re: ArduinoISP programming Atmega8515 on breadboard
|
on: March 12, 2012, 06:35:55 pm
|
Unless I've missed something, you don't ever need a cap between +5v and reset.
You DO, however, want the 10K resistor between +5v and reset -- this pulls it high unless grounded to reset.
Just to clarify, the cap is between +5v and RST on the Arduino being used as the ISP, the 10k resistor is between +5v and RST on the chip being programmed... correct? Also, I'm using a crystal with 22u caps, so no issue there, and my multimeter says the PSU is running @ 4.97V so that's good as well. Goodwill FTW 
|
|
|
|
|
14
|
Using Arduino / Microcontrollers / Re: ArduinoISP programming Atmega8515 on breadboard
|
on: March 09, 2012, 11:42:04 pm
|
Ok, so other than the resistor and caps being the wrong value (just threw in ones I had lying around for the sake of the picture, I'll get the right ones tomorrow) does this hookup look right? The wires are: Ard. 8515 RED: MISO 50 7 YLW: MOSI 51 6 GRN: SCK 52 8 BLUE: SS 53 9 The crystal is between 18 and 19, with a cap on either side of it each connected to GND. Pin 40 on the 8515 is tied to +5v and pin 20 goes to GND. Breadboard GND is tied to Arduino GND, Arduino +5v is bridged to Arduino RESET by a 100nF cap. 10k resistor between the 8515 pin 9 (RESET) to GND Breadboard has external +5v source (using an old phone charger I picked up at Goodwill  ) Anything else I'm missing? Here's the 8515 pinout for reference http://circuits.datasheetdir.com/18/ATMEGA8515-pinout.jpg
|
|
|
|
|