Show Posts
Pages: [1] 2 3 ... 177
1  Using Arduino / Programming Questions / Re: How to share code? on: Today at 12:56:25 am

I'm still trying to figure out this GitHub thing. Its trying to keep version control on hidden desktop folder info. and stuff. I'm not sure how to tell it to ignore all that.
git only tracks the files you tell it to track.
If you accidentally told it to track those files, then use git to remove them.
The files can still exist but they won't be part of the repository and won't be tracked.

--- bill
2  Using Arduino / Displays / Re: U8glib: Graphics Lib for LCDs and OLEDs on: July 29, 2014, 07:40:29 pm
I will grab the gcc toolchain and give it a shot.
Jacob
If you are using the IDE, then you already have everything you need
as the IDE comes with the avr-gcc tools and the avr version of gnu binutils.
--- bill
3  Using Arduino / Microcontrollers / Re: Which microcontroller/board should I use? on: July 29, 2014, 07:36:09 pm
If you really need 32 bit and want to stay with the Arduino IDE then your choices are a bit limited.
It definitely eliminates all the 8 bit AVR based products.
The Teensy 3.x platform is really nice. Paul has added many capabilities above and
beyond the standard Arduino IDE so the Teensy products not only have additional
features but tend to just work better even when using Arduino core APIs.

There are some nice pic32 based micro-controllers, including in DIP packages,
that also fit your stated requirements.
Search for chipKIT.
Here is a link about using a DIP version.
http://chipkit.net/diy-chipkit-board/

What you haven't stated is your i/o requirements like number of i/o pins,
output power requirements, native USB support,
and if you need 5v tolerant inputs on your 3.3v pins.

In terms of something that meets your initial requirements, works today at  3.3v with 5v tolerant inputs,
it is hard to beat the Teensy 3.1

If you still want small and are ok with 5v only or 3v only and 8bit, then then the Teensy 2 and Teensy 2++ with
the micro sd adapter can keep things really small:
https://www.pjrc.com/store/sd_adaptor.html

One really nice advantage of leaving the 8 bit AVR world behind is that you no longer have to deal with
all the PROGMEM "crap". You just declare you data const and everything works the
way the C language intended it to work.
No messing with kludgey declarations, no lookups, no special functions, or access routines.
const data "just works".

--- bill
4  Using Arduino / Displays / Re: U8glib: Graphics Lib for LCDs and OLEDs on: July 29, 2014, 06:07:51 pm
Without looking at the actual final linked image to see everything and
what is linked in you are dancing in the dark.

Previously you said you did this,  but now it sounds like you haven't.

The gcc tool set comes with a set of binutils. There is a tool "objdump" to look at .elf files
The avr-gcc tool package that comes with the IDE comes with the gcc binutils.
In that package,  objdump is called "avr-objdump"
I recommend using that with the -S and -h options.

--- bill
5  Using Arduino / Displays / Re: U8glib: Graphics Lib for LCDs and OLEDs on: July 29, 2014, 12:02:01 am
I have, and there is a large chunk there. A lot of stuff in the code is, for example dedicated to constructors for devices that may or may not be invoked during run-time - not compile time, so I think I can save a fair bit of space if I trim it to the bone.

Or, end up with a non-functioning library as I sever a vital organ. Hence asking the author for his thoughts as I head in.

Cheers
Jacob
So you created a listing file from the .elf file and actually saw dead code that isn't called and constructor code
for other devices in the linked image?

When I built the "HelloWorld" example for the i2c SD1306 128x64 module for a UNO board,
I only saw the routine for the one expected constructor and not any others.

I'm curious what you saw.

--- bill
6  Using Arduino / Displays / Re: U8glib: Graphics Lib for LCDs and OLEDs on: July 28, 2014, 11:39:09 pm
I have a suspicion more is tacked on, used or not when it comes to libraries... thoughts? Otherwise I am going to just make a copy of the library and just try the slash, burn and see method smiley
Before running off and spending time on a hunch, why not just take a look and
actually see where all the space is going?
Create a listing file from the linked image and you will see all the code generated
and linked in.
That will tell you exactly what is being linked in and how big things are.

--- bill
7  Using Arduino / Programming Questions / Re: How to share code? on: July 28, 2014, 04:19:48 pm
A ReadMe file can be a good thing, they look better if written in Markdown, so that is worth learning as well. FWIW, here is a recent library I posted.
I agree.
A ReadMe at the top level to explain what the "blob" of directories are,
but then the code itself should be commented.
Also, don't forget about the licensing terms.
I'd recommend at least having a license.txt file that explains the general licensing terms.
For absolute clarity, especially if the licensing is something other than public domain,
it is best that every file,  have the licensing terms clearly spelled out in it
so when the file is separated from the tree, the licensing terms follow with the file.

IMHO, to be good examples, especially for newbies, the sketches should have a large comment
at the top explaining what the sketch does, what hardware is needed, and how to hook it up.
That way people know how to hook up the hardware and know the expected behavior should
things not appear to be working correctly.

It is also helpful to have comments in the code along the way to help explain how the code works.

Comments are a big help when coming  back to the code 2, 3, 5+ years later and
trying to figure out what it did and how it worked.


--- bill

8  Using Arduino / Project Guidance / Re: RTC on: July 28, 2014, 12:01:20 am
Most projects get by with one clock, so you might explain why you need this to be so complicated. If your needs are valid, you are probably still going about it the wrong way, and I bet you also have the wrong clock.
Many projects use the Time library. The point of the Time library is track time using epoch time
which is really the best way to track time as it makes doing many other things much easier.
The Time library integrates with several other libraries like TimeAlarms and TimeZone for additional
capabilities.

The value of epoch time is it gives you a universal timestamp that is totally independent of
time zone.

If all that is ever needed  is to display a local time in human readable form and things like
timestamps, or alarms, or other time offset type calculations are not needed, then epoch time and hence
the Time library is probably not necessary.
Just set the RTC to localtime and read it whenever you need the date/time.


The Time library tracks time the same way unix does, it tracks time based on the number of seconds
since midnight Jan 1970 UTC.

When using this type of epoch time, the timestamp (time_t values) makes calculating
time deltas as easy as simple addition or subtraction. Such is not the case when using
human readable time formats - which is how the RTCs track time.

Just think of how to calculate something as easy as 1 minute from now.
With epoch time you take the epoch time of "now" and simply add 60.
With human readable time, you have do all kinds of checks for roll overs of
minutes, hours, years, months, years,  and even leap year stuff comes into play.
With epoch time everything is seconds until you need it to be human readable and
then it gets converted.

Once the time in the Time library set,  the Time library uses the millis() clock to track time.
In order to have better accuracy than the AVR clock,
the epoch time down in the Time library will need to be periodically synchronized to something more accurate.
The Time library has the ability to configure a routine for synchronization and how often call it
using setSyncProvider() and setSyncInterval()

The library includes examples for how to use it.
Depending on the accuracy of your AVR clock, syncing the time at midnight might
still allow quite a bit of drift.
Rather than syncing at a specific time, it might better to sync it periodically using
the sync provider functions in the Time library. Sync it every so many minutes
5, 10, 60, 120, etc... whatever you think provides the needed accuracy.


As rob mentioned some RTCs drift more than others,
The DS3231 is one of the better ones as it is temperature compensated.

--- bill
9  Using Arduino / Microcontrollers / Re: Smallerst arduino on: July 25, 2014, 04:21:14 pm
From what I saw, the only issue is that Linux enforces permissions on accessing the USB so libUSB (which avrdude uses)
can't access the USB & device as a non root user until you create and install the proper udev rule.
This is typically the case with any type of USB type device.
I've had to do this with the AVR dragon, USBasp, and Teensy boards as well.

--- bill

Thats silly. I had to do that with the arduino itself to have permissions to use the serial port, so pretty much standard then. Why would they say unsupported?
While there are places that say linux isn't supported,
there are also references to linux support.
https://learn.adafruit.com/introducing-trinket/setting-up-with-arduino-ide


I don't have a Trinket board so I can't verify anything,  but since
it looks like USBtiny I would htink that  it should work the same on
all the OSs given that avrdude is what is actually talking to it.

Another thing they might have run into is that
there has been a long standing bug (bad design) in the IDE
that required opening a serial port even when an ISP programmer was used.
If you have no serial port, you can't program using an ISP programmer.
This has been "fixed" in the recent 1.5x releases.
The fix is a total kludge in that it still looks for and will open serial ports
but now instead of failing to proceed if it can't find any serial ports,
it will continue on and use the ISP programmer.

--- bill


10  Using Arduino / Microcontrollers / Re: Smallerst arduino on: July 25, 2014, 03:26:36 pm
The attiny85 looks nice, but not working in Linux is putting me off.
Huh?
What do you mean?


That was for one of the boards someone recomended earlier, that had a usb bootloader that wasnt supported on lixux
I ordered 10 of them as a bunch of some other stuff, for now will be programming them using AVRISP MK2
If you are refering to the Adafruit Trinket, it does support Linux just fine since it looks just like a USBTiny ISP programmer.
From what I saw, the only issue is that Linux enforces permissions on accessing the USB so libUSB (which avrdude uses)
can't access the USB & device as a non root user until you create and install the proper udev rule.
This is typically the case with any type of USB type device.
I've had to do this with the AVR dragon, USBasp, and Teensy boards as well.

--- bill
11  Using Arduino / Microcontrollers / Re: Can't Program ATTiny45: "No Arduino.h" on: July 24, 2014, 06:33:49 pm
"IDE" The programming software.
Obviously.

But you said that you  have Arduino IDE version 2.0.4
And that is what I'm asking about. version 2.0.4 ????
And where did you get it?


--- bill
12  Using Arduino / Microcontrollers / Re: Can't Program ATTiny45: "No Arduino.h" on: July 24, 2014, 05:21:29 pm
I'm using Linux and the 2.0.4 IDE

2.0.4 IDE ????
13  Using Arduino / Microcontrollers / Re: Smallerst arduino on: July 24, 2014, 05:19:40 pm
The attiny85 looks nice, but not working in Linux is putting me off.
Huh?
What do you mean?

I've been playing with tiny85's for several years on linux.
I've burned images using either an AVR dragon or a USBasp device
from both the Arduino IDE and my own makefiles when I don't want
to use Arduino.
I've even source level debugged  code on the tiny85 using the AVR
dragon using debugWire.
Pretty cool to be source level debugging an 8 pin dip.
It is easier to do when using your own makefiles but it can
be also done with Arduino code.
It is a pain to setup and get all the deamons up and going
when using the Arduino IDE given the way the IDE works,
but it can be done.

--- bill
14  Using Arduino / Programming Questions / Re: Libusb help on: July 22, 2014, 05:41:40 pm
You don't open a USB port to get a PC to talk to an Arduino.
If using libusb you do.
That is the entire point of libusb.
You open a connection to a device bulk end point and push data at it.
It is Host USB (PC) talking to Device USB (the leonardo) directly over USB.

To get a feel for libusb and the API functions, have a look at the documentation here:
Code:
http://libusb.sourceforge.net/doc/
If you google you can find lots of information out there on libusb

The challenge when using the Arduino environment is going to be that it has no debugging environment
The only way that is typically used is sending character data (printed messages)
from the Arduino board over a serial or virtual serial interface back to the host.
The default serial interface is named "Serial".
On Leonardo, that "serial" interface uses a virtual serial interface over USB.
But in this case, you can't use that because you will be using the USB for raw USB communication
with libusb.

If you had an AVR dragon, or a AVR ICE you could use Atmel Studio instead of the Arduino IDE
and have full source level debugging.
It can be done with the Arduino IDE (I've done it) but it is not easy to set up and I'm not sure
it could be done on Windows.

In the absence of source level debugging,
What you can do is use the USB for your libusb communication
and then use the real UART inside the 32u4 for your serial port.
It will be Serial1 instead of Serial.
See this:
http://arduino.cc/en/Guide/ArduinoLeonardoMicro?from=Guide.ArduinoLeonardo
RX will be pin 0 and TX will be pin 1.
You will need some sort of way to read the serial port data on the host.
Something like an FTDI cable or USB to TTL  module.

If you have to build the code on the PC vs the teacher giving you pre-compiled
executables, then you are going to need to set up a build environment.
You will need compilers, libraries, binutils, editor, make, shell,  revision control tools, etc...
Your teacher should be able to assist for that as I'm assuming the exercise is about
writing code to use USB communications using libusb vs how to locate and set up
all the needed tools to to create a build environment on Windows.
With linux, it is much simpler to do development since
all the tools are native and  pretty much built in,
since unix was designed by developers to do development.

Hope that helped.

--- bill




15  Using Arduino / Programming Questions / Re: Fast DigitalWrite, made from Wire lib source on: July 21, 2014, 07:27:47 pm
You removed the  set HIGH and LOW macros in fio_shiftOut() and then modified the code to
change the way the |= and &= operations were done and broke it.

This code is Oring in 1 bits to all the bits in the register but the correct one.
The AND is still stripping off the desired bit.

So the correct bit in the register is never getting set while corrupting
all the other bits in the register.
You can either fix the OR operation or go back to using the macros.

In terms of masking interrupts, the FIO code used the ATOMIC block macro
to ensure atomicity. It does mask interrupts but did it in a way that guaranteed
that the optimizer would never re-order the code - which is a risk depending
on how the code is written.
Worst case the re-ordering moves the interrupt mask and it no longer keeps
the operation atomic.

For portability to non AVR processors, you can re-define/create the ATOMIC macro when on other processors
just like the FIO code did.

In terms of what to make atomic, you will have decide whether to block
for the entire shift operation (slightly faster - but delays interrupts a bit longer),
or just during the bit twiddling of the register, which keeps interrupts masked
as short as possible.
The FIO code chose to minimize interrupt blocking.

--- bill


Pages: [1] 2 3 ... 177