Digistump Forums
The Digispark => Digispark (Original) Support => Topic started by: zapta on October 24, 2013, 10:34:06 pm
-
Hi everybody, an Arduino newbie here. I plan to do a small project and ordered a digispark and a digispark programming tool (haven't got it yet).
While debugging my programs, I would like to have a basic printf capabilities and see the output on my development computer (Max OSC 10.8.5, mac book air 11", if it matters). My plan is to have the digispark plugged into the computer and powered by it while I edit, load, debug.
1. What are my options for printf? Does the arduino already support it out of the box? Do you need to designate one pin for UART and connect it to the computer? (I do have a serial to USB board which I used with teensy boards). Can I have a serial TX only pin without scarifying a pin for RX? What serial library should I use, Arduino serial or digispark soft serial?
2. Can I power the digispark from the computer (usb port) while debugging the program? (will this require to change the boot loader to the no-delay version that use an explicit input to trigger loading?).
3. Do I need to short the USB +V diode? Should I remove the on board regulator (to avoid 5V on its output with no input voltage?)
Any hint will be greatly appreciated. The more detailed, the better.
Thanks,
Zapta
-
I've normally used the DigiUSB library on the Digispark, and one of the USB monitor programs (included with the Digispark Arduino download) on the computer side. From what I've read, the SoftSerial library should work (assuming you have a separate USB-to-Serial adapter), but I haven't tried it myself.
You can power the Digispark via USB without having to use any other USB functionality. The only reason to change the bootloader to no-delay is if you just don't want the 5-second check-for-programming delay in your application. I've never used it, myself.
I'm not sure why you're asking about the diode and power regulator?
-
1. What are my options for printf? Does the arduino already support it out of the box? Do you need to designate one pin for UART and connect it to the computer? (I do have a serial to USB board which I used with teensy boards). Can I have a serial TX only pin without scarifying a pin for RX? What serial library should I use, Arduino serial or digispark soft serial?
As Dougal said, DigiUSB is possibly the easiest out of the box, although you'll have to use something like the DigiUSB.exe program to talk to the DigiSpark, rather than a conventional serial program (I often use PuTTY with our Teensy's). The downside of DigiUSB is that it eats up 3½k of your program memory, and over 300 bytes of the 512 bytes of RAM, which I found can very easily cause strange behaviour to manifest itself if you use up all of the remaining RAM.
2. Can I power the digispark from the computer (usb port) while debugging the program? (will this require to change the boot loader to the no-delay version that use an explicit input to trigger loading?).
Using USB power is fine, and the easiest approach. You can get strange things happening sometimes though. I've been using the Charlieplexing shield, which results in toggling of the USB port bits, and Windows seems to see that as something not working on the USB port, so you can get repetitive warning messages about a USB device not working, or drivers not being found. An external USB power supply solves those sort of issues (and obviously would other power connected to the Vin pin on JP2).
3. Do I need to short the USB +V diode? Should I remove the on board regulator (to avoid 5V on its output with no input voltage?)
The DigiSpark should just work, out of the box, regardless of whether you power it over the USB interface or with an external power supply. You shouldn't need to change anything. What are you worried about, that you think requires changes to be made to the board?
-
Good point about spurious signals on the USB data lines, if you are using pins 3 & 4 for your projects. You can use a USB wall-wart adapter along with a cable that has a female USB-A end for powering the Digispark, too. Or any number of available battery-powered boost circuit boards with USB connectors.
I've used a car USB adaptor with a USB extension cable (male on one end, female on the other) to plugin in a Digispark to drive some LEDs before. Tapping into the power regular inputs is easy enough, if you need to use more arbitrary voltage sources, though.
Also, if you get the LCD shield, that could be another good place to send debug info, especially if you are going to be using other I2C devices in a project.
-
Thanks dougal and TimO, this is very useful. I will give the DigiUSB library a try.
Is the DigiUSB program available for the Mac?
Regarding the power
1. Looking at this schematic, how is the board powered from the USB port? The diode D3 seems to be in the wrong direction.
https://s3.amazonaws.com/digistump-resources/files/97a1bb28_DigisparkSchematic.pdf
2. After having the program working I want to power the board with 5V through JP2 pin 3 (not using USB). This means that regular V1 will get 5V at its output without voltage in its input. Is this within the operating specification of regulator? (or should I remove it).
-
The diode is facing the wrong direction in the schematic - but correct on the board.
DigiUSB comes with the files for all three platforms and works with all of them.
2) Yes this is within spec and as designed for 5v direct power - "it works out of the box" for any of the 3 power options (USB, 5V, VIN) no changes necessary.
-
Awesome! Thanks digistump.
-
Hi Digistump,
Got the board by mail today, thanks. Connected it to Mac book air 10.8.5 and was able to compile and download programs using the Arduino IDE. I am trying now to make the print to work using DigiUSB. Looked at few examples and came up with this program
#include <DigiUSB.h>
#define LED 1
unsigned long cycle_base_millis;
void setup() {
DigiUSB.begin();
pinMode(1, OUTPUT);
}
void loop() {
DigiUSB.refresh();
const long millis_in_cycle = millis() - cycle_base_millis;
if (millis_in_cycle <= 950) {
digitalWrite(LED, LOW);
return;
}
if (millis_in_cycle <= 1000) {
digitalWrite(LED, HIGH);
return;
}
DigiUSB.println("Cycle");
cycle_base_millis = millis();
}
When the program runs, LED blinks as expected and I see few print messages using the receive program but not for long (see log below).
What am I doing wrong?
BTW, I see in the directory of the recieve command also these files, do I need to do anything with them? libusb-0.1.4.dylib libusb-1.0.0.dylib libusb-config
DigisparkArduino-MacOSX-1.0.4-May19/DigiUSB Programs$ ./receive --debug
Detecting USB devices...
Detected DigiSpark...
Found 1 interfaces, using interface 0
Read from Digispark: Cycle
Cycle
Cycle
Cycle
Cycle
Cycle
Cycle
Cycle
Cycle
Cycle
Cycle
Cycle
Error -2 releasing Interface 0
DigisparkArduino-MacOSX-1.0.4-May19/DigiUSB Programs$
-
receive just reads until it goes to read and the buffer is empty - you want to use digiusb (in the same folder) to keep the connection open and keep recieving
-
The diode is facing the wrong direction in the schematic - but correct on the board.
I recall looking at the schematic and coming to that conclusion, since the arrangement on the schematic would basically cause problems, for no net gain, when reversing the diode obviously blocks a board generated +5V from going out over the USB, which would be a "bad thing".