Show Posts
Pages: 1 ... 3 4 [5]
61  Forum 2005-2010 (read only) / Interfacing / Re: Serial LCD's  Any good on: September 04, 2010, 04:20:26 pm
Thanks.  I had thought about changing the speed, but this requires sending the command byte sequence, and I'm not sure I can do this reliable.  Note on the 160x128  LCD it defaults to 115200, and I still need delays.   I'll play with the 16x2 baud rate and see if I can get improvements.  Yes I plan on setting position and just replacing the value, but I'm just testing now.  
62  Forum 2005-2010 (read only) / Interfacing / Re: Serial LCD's  Any good on: September 04, 2010, 03:24:37 pm
Btw I have looked at the data sheets for both..  I may of course be missing something
63  Forum 2005-2010 (read only) / Interfacing / Re: Serial LCD's  Any good on: September 04, 2010, 03:23:43 pm
LCD-9067
And
08884 (this is the larger one)

I've okayed with delays, and 15ms seems to work consistently,  ov course this really is a pain
64  Forum 2005-2010 (read only) / Interfacing / Re: Serial LCD's  Any good on: September 04, 2010, 02:24:34 pm
I'm using spark funs 16x2 serial LCD right now.  I had one of the bigger ones which exhibits similar behavior (this one uses an avr processor, the small one uses a pic)
65  Forum 2005-2010 (read only) / Interfacing / Re: Serial LCD's  Any good on: September 04, 2010, 01:36:52 pm

uint8_t clearsc[]={0x7C,0x01};
uint8_t blight[]={0x7c,157};

uint8_t screenpos[]={254,66};

void setup() {
  Serial.begin(9600);
  Serial1.begin(9600);

      Serial1.write(clearsc,2);
      delay(15);
}

unsigned int refv=5;
unsigned int milli_volts(unsigned int input){

      float v = refv *((float)input/1024);
      return (v*1000);
}

unsigned int reading;

void loop() {

      reading = analogRead(0);      
      Serial.print("Reading:");Serial.println(reading);
      Serial.print("MV:");Serial.println(milli_volts(reading));
      
      screenpos[1]=1;
      Serial1.write(screenpos,2);
      delay(15);
      Serial1.print("Reading:");Serial1.print(reading);
      delay(15);
      screenpos[1]= 64 + 128;
      Serial1.write(screenpos,2); delay(5);
      Serial1.print("MV:");Serial1.print(milli_volts(reading));
      delay(15);
      while(!Serial.available());
      Serial.flush();
}
66  Forum 2005-2010 (read only) / Interfacing / Re: Serial LCD's  Any good on: September 04, 2010, 01:36:39 pm
here is my sketch
67  Forum 2005-2010 (read only) / Interfacing / Serial LCD's  Any good on: September 04, 2010, 01:36:14 pm
I'm beginning to think that these Serial LCD's are pretty much junk.  About 3 times out of 10, sending the clear command on a hardware serial (Mega, Serial1) actually clears the screen. .the rest of the time it prints ||.   Possession selection is a little better, but it is very dependent on a delay after sending the position command before writing anything.
68  Forum 2005-2010 (read only) / Interfacing / Re: Serial Enabled 16x2 LCD - Red on Black 3.3V on: September 03, 2010, 01:23:51 pm
I have one of these LCD's  using the hardware serial port, all commands work fine.  but with NewSoftSerial  the clear command just prints || across the screen.  Baudrate is 9600 on both Hardware and Software.

The other thing i notice when using hardware, when i set the line to 1 the text prints dark, when i set the line to2 (2x16 LCD 5v from sparkfun) the text is very light
69  Forum 2005-2010 (read only) / Interfacing / Re: Mega on battery on: August 13, 2010, 10:28:58 am
yep.. grounded properly etc.  
70  Forum 2005-2010 (read only) / Interfacing / Mega on battery on: August 13, 2010, 08:04:10 am
I have a SparkFun LCD backpack that I have a simple hello world program working on.  However, it only seems to work when I have the Mega powered through the USB.  I have a 9v battery connected to the 2.1mm barrell connector. and the board is powered up properly.. but nothing displays on the LCD (which I have powered with a separate battery pack (4 AA batteries)

This is my simple code
//DEMO

uint8_t reset[]={0x7C,0x00};
uint8_t demo[]={0x7c,0x04};
uint8_t reverse[]={0x7c,0x12};
uint8_t blight[]={0x7C,0x02,0x30};
void setup()
{
//Serial.begin(9600);
//Serial.println("Preping Serial 1");
Serial1.begin(115200);
Serial1.write(reset,2); delay(10);
Serial1.write(blight,3);
Serial1.write(reverse,2); delay(10);
Serial1.print("Hello World!");
//Serial.println("hello world on lcd");
delay(10000);
Serial1.write(reset,2);
//Serial.println("Screen should be clear now");
delay(10000);
Serial1.write(demo,2);
//Serial.println("Splash displayed");
}

void loop()
{

}
71  Forum 2005-2010 (read only) / News / Re: DuinOS: small and simple rtos on: October 04, 2010, 06:32:20 pm
I actually seem to have fixed the problem when I went back and simplified some of the code.  Things seem to be working fine now.. I will roll back to 0.1 if I run into more problems.  
72  Forum 2005-2010 (read only) / News / Re: DuinOS: small and simple rtos on: October 04, 2010, 04:08:22 pm
I've really embraced using DuinOS for my project.   But I'm noticing some strange behaviors when using serial on an Arduino MEGA.  I have a few tasks, one which reads data from Serial2 which is a GPS device, another which handles reading various sensors (accelerometer, voltage (0-1v)) and processes a tachometer input (the input is handled by an interrupt, which increments a counter, ever 250ms, the handler task runs and converts it to RPM).   All of these tasks queue messages to a handler task which will output through Serial2 to a Arduino Pro Mini which will drive a LCD display.   In the QueueHandler function, if I only do a "Serial.print" of a string, everything works fine.  When I try and Serial.print data from the queued message things just hang.  Things also hang when I try and Serial2.write out to the Pro Mini.

Sometimes the led on Pin 13 blinks, sometimes it goes solid, but in most cases it just remains off.

Anyone have any ideas what may be the issue here.

I'd post the code, but its quite large.  I'm happy to send via email.  Note, I've tried playing with stack sizes on the tasks when they are created going as large as 4K.  No joy there.
73  Forum 2005-2010 (read only) / News / Re: DuinOS: small and simple rtos on: October 01, 2010, 08:28:43 am
Using Make and the DuinOS

I've made a makefile (based on a makefile from a post in another thread) that builds DuinOS and your sketch.   This makefile builds the sketch that was posted in the very beginning of the thread.  The makefile assumes that the sketch is DuinOSTest.pde.  Note, this is from a MAC, but it should be easy to modify for linux or even windows


TARGET = $(notdir $(CURDIR))
#INSTALL_DIR = $(HOME)/arduino-0018

# This is the location on the MAC
INSTALL_DIR = /Applications/Arduino.app/Contents/Resources/Java
# Serial port which I always connect my MEGA to
PORT = /dev/tty.usbserial-A900ceXD
UPLOAD_RATE = 57600
AVRDUDE_PROGRAMMER = stk500v1
#MCU = atmega168
# Processor for the Arduino Mega
MCU = atmega1280
F_CPU = 16000000

############################################################################
# Below here nothing should be changed...

VERSION=18
# Location of the boards file
ARDUINO = $(INSTALL_DIR)/hardware/arduino/cores/arduino.DuinOS
AVR_TOOLS_PATH = $(INSTALL_DIR)/hardware/tools/avr/bin
#AVR_TOOLS_PATH = /usr/local/CrossPack-AVR-20100115/bin
#AVR_TOOLS_PATH = /usr/bin
#AVRDUDE_PATH = $(INSTALL_DIR)/hardware/tools
AVRDUDE_PATH = $(INSTALL_DIR)/hardware/tools/avr/bin
#These are all the C language files for Arduino and the DuinOS
C_MODULES =  \
$(ARDUINO)/wiring_pulse.c \
$(ARDUINO)/wiring_analog.c \
$(ARDUINO)/pins_arduino.c \
$(ARDUINO)/wiring.c \
$(ARDUINO)/wiring_digital.c \
$(ARDUINO)/WInterrupts.c \
$(ARDUINO)/wiring_shift.c \
$(ARDUINO)/DuinOS/croutine.c  \
$(ARDUINO)/DuinOS/heap_1.c  \
$(ARDUINO)/DuinOS/heap_2.c  \
$(ARDUINO)/DuinOS/heap_3.c  \
$(ARDUINO)/DuinOS/list.c  \
$(ARDUINO)/DuinOS/port.c  \
$(ARDUINO)/DuinOS/queue.c  \
$(ARDUINO)/DuinOS/tasks.c  \
# end of C_MODULES

#These are all the CPP language files for Arduino and the DuinOS
CXX_MODULES = \
$(ARDUINO)/Tone.cpp \
$(ARDUINO)/main.cpp \
$(ARDUINO)/WMath.cpp \
$(ARDUINO)/Print.cpp \
$(ARDUINO)/HardwareSerial.cpp \
# end of CXX_MODULES

# Variable for where my sketches are kept
SKETCHHOME=/Users/sbade1/Documents/Arduino

#Vpath simplifies MAKE finding source files

VPATH = ../libraries/SdFat:../libraries/SoftI2cMaster:../libraries/TwiMaster:../libraries/TinyGPS:$(ARDUINO):$(ARDUINO)/DuinOS

CXX_APP = applet/$(TARGET).cpp
# Additional CPP files - library files would be specified here
CXXFILES =


MODULES = $(C_MODULES) $(CXX_MODULES) $(CXXFILES)
SRC = $(C_MODULES) $(CXXFILES)
CXXSRC = $(CXX_MODULES) $(CXX_APP) $(CXXFILES)
FORMAT = ihex


# Name of this Makefile (used for "make depend").
MAKEFILE = Makefile

# Debugging format.
# Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.
# AVR (extended) COFF requires stabs, plus an avr-objcopy run.
#DEBUG = stabs
DEBUG =

OPT = s

# Place -D or -U options here
CDEFS = -DF_CPU=$(F_CPU)L -DARDUINO=$(VERSION)
CXXDEFS = -DF_CPU=$(F_CPU)L -DARDUINO=$(VERSION)

# Place -I options here
# Local includes for the project
CINCSLOCAL = -I$(ARDUINO) -I`pwd` -I$(ARDUINO) -I$(ARDUINO)/DuinOS

CINCS = -I$(ARDUINO) -I`pwd` $(CINCSLOCAL)
CXXINCS = -I$(ARDUINO) -I`pwd` $(CINCSLOCAL)

# Compiler flag to set the C Standard level.
# c89   - "ANSI" C
# gnu89 - c89 plus GCC extensions
# c99   - ISO C99 standard (not yet fully implemented)
# gnu99 - c99 plus GCC extensions
#CSTANDARD = -std=gnu99
CDEBUG = -g$(DEBUG)
#CWARN = -Wall -Wstrict-prototypes
#CWARN = -Wall   # show all warnings
CWARN = -w      # suppress all warnings
####CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
CTUNING = -ffunction-sections -fdata-sections
CXXTUNING = -fno-exceptions -ffunction-sections -fdata-sections
#CEXTRA = -Wa,-adhlns=$(<:.c=.lst)

CFLAGS = $(CDEBUG) -O$(OPT) $(CWARN) $(CTUNING) $(CDEFS) $(CINCS) $(CSTANDARD) $(CEXTRA)
CXXFLAGS = $(CDEBUG) -O$(OPT) $(CWARN) $(CXXTUNING) $(CDEFS) $(CINCS)
#ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
LDFLAGS = -O$(OPT) -lm -Wl,--gc-sections


# Programming support using avrdude. Settings and variables.
AVRDUDE_PORT = $(PORT)
AVRDUDE_WRITE_FLASH = -U flash:w:applet/$(TARGET).hex

#AVRDUDE_FLAGS = -V -F -C $(INSTALL_DIR)/hardware/tools/avr/etc/avrdude.conf \

AVRDUDE_FLAGS = -V -F -C $(INSTALL_DIR)/hardware/tools/avr/etc/avrdude.conf \
-p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) \
-b $(UPLOAD_RATE)

# Program settings
CC = $(AVR_TOOLS_PATH)/avr-gcc
CXX = $(AVR_TOOLS_PATH)/avr-g++
LD = $(AVR_TOOLS_PATH)/avr-gcc
OBJCOPY = $(AVR_TOOLS_PATH)/avr-objcopy
OBJDUMP = $(AVR_TOOLS_PATH)/avr-objdump
AR  = $(AVR_TOOLS_PATH)/avr-ar
SIZE = $(AVR_TOOLS_PATH)/avr-size
NM = $(AVR_TOOLS_PATH)/avr-nm
AVRDUDE = $(AVRDUDE_PATH)/avrdude
REMOVE = rm -f
MV = mv -f

# Define all object files.
OBJ = $(SRC:.c=.o) $(CXXSRC:.cpp=.o) $(ASRC:.S=.o) $(CXXFILES:.cpp=.o)
OBJ_MODULES = $(C_MODULES:.c=.o) $(CXX_MODULES:.cpp=.o) $(CXXFILES:.cpp=.o)

# Define all listing files.
LST = $(ASRC:.S=.lst) $(CXXSRC:.cpp=.lst) $(SRC:.c=.lst)

# Combine all necessary flags and optional flags.
# Add target processor to flags.
ALL_CFLAGS = $(CFLAGS) -mmcu=$(MCU)
ALL_CXXFLAGS = $(CXXFLAGS) -mmcu=$(MCU)
ALL_ASFLAGS = -x assembler-with-cpp $(ASFLAGS) -mmcu=$(MCU)
ALL_LDFLAGS = $(LDFLAGS) -mmcu=$(MCU)

# Default target.
all: applet_files build sizeafter

build: elf hex

#applet_files: $(TARGET).pde
applet/$(TARGET).cpp: $(TARGET).pde
      # Here is the "preprocessing".
      # It creates a .cpp file based with the same name as the .pde file.
      # On top of the new .cpp file comes the WProgram.h header.
      # and prototypes for setup() and Loop()
      # Then the .cpp file will be compiled. Errors during compile will
      # refer to this new, automatically generated, file.
      # Not the original .pde file you actually edit...
      test -d applet || mkdir applet
      echo '#include "WProgram.h"' > applet/$(TARGET).cpp
      echo 'void setup();' >> applet/$(TARGET).cpp
      echo 'void loop();' >> applet/$(TARGET).cpp
      cat $(TARGET).pde >> applet/$(TARGET).cpp

elf: applet/$(TARGET).elf
hex: applet/$(TARGET).hex
eep: applet/$(TARGET).eep
lss: applet/$(TARGET).lss
sym: applet/$(TARGET).sym


foo:
      echo $(LST)

# Program the device.  
upload: applet/$(TARGET).hex
      $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)


      # Display size of file.
HEXSIZE = $(SIZE) --target=$(FORMAT) applet/$(TARGET).hex
ELFSIZE = $(SIZE)  applet/$(TARGET).elf
sizebefore:
      @if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(HEXSIZE); echo; fi

sizeafter:
      @if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(HEXSIZE); echo; fi


# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
COFFCONVERT=$(OBJCOPY) --debugging \
--change-section-address .data-0x800000 \
--change-section-address .bss-0x800000 \
--change-section-address .noinit-0x800000 \
--change-section-address .eeprom-0x810000


coff: applet/$(TARGET).elf
      $(COFFCONVERT) -O coff-avr applet/$(TARGET).elf $(TARGET).cof


extcoff: $(TARGET).elf
      $(COFFCONVERT) -O coff-ext-avr applet/$(TARGET).elf $(TARGET).cof


.SUFFIXES: .elf .hex .eep .lss .sym

.elf.hex:
      $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@

.elf.eep:
      $(OBJCOPY) -O $(FORMAT) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
      --no-change-warnings \
      --change-section-lma .eeprom=0 $< $@

# Create extended listing file from ELF output file.
.elf.lss:
      $(OBJDUMP) -h -S $< > $@

# Create a symbol table from ELF output file.
.elf.sym:
      $(NM) -n $< > $@

      # Link: create ELF output file from library.
#applet/$(TARGET).elf: $(TARGET).pde applet/core.a
applet/$(TARGET).elf: applet/$(TARGET).o applet/core.a
      $(LD) $(ALL_LDFLAGS) -o $@ applet/$(TARGET).o applet/core.a

applet/core.a: $(OBJ_MODULES)
      @for i in $(OBJ_MODULES); do echo $(AR) rcs applet/core.a $$i; $(AR) rcs applet/core.a $$i; done



# Compile: create object files from C++ source files.
.cpp.o:
      $(CXX) -c $(ALL_CXXFLAGS) $< -o $@

# Compile: create object files from C source files.
.c.o:
      $(CC) -c $(ALL_CFLAGS) $< -o $@


# Compile: create assembler files from C source files.
.c.s:
      $(CC) -S $(ALL_CFLAGS) $< -o $@


# Assemble: create object files from assembler source files.
.S.o:
      $(CC) -c $(ALL_ASFLAG
74  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: Automotive G-Force mesurement with arduino? on: September 16, 2010, 02:09:33 am
I'm actually working on a similar project.  Targeted for road racing DAQ and in car dash.  My tests with the ADXL320 (going from memory here) Accelerometer show that it is as accurate as my $1500 DAQ/DASH system is for measuring X and Y axis.  For the GPS i'm using the Venus with SMA connector from sparkfun, which looks like it will do WAAS which should bring the accuracy up.

I will be splitting the function, using a MEGA for the actual DAQ and sensor input (non OBDII car) for Tach, Ignition Advance (my crankfire ignition provides for advance in degrees by outputing between 0-1 volts, so an analog input works for this.  Tach is something (I'm no hardware engineer) that I'm still working out, as my tach signal is a 12v Square wave, and I need to take that to a 5v Square wave.  The display will be driven by a Pro Mini which takes serial input from the MEGA.

The part I'm still working out is the GPS.  I have the GPS receiver working, but I think that to much of the mega processing will be taken up with receiving the NMEA strings and parsing them.  I will also be using a button which the driver sets start/finish.  Using the Lat/Long from the GPS when the button is pressed, and the course data, I'll calculate a "line" perpendicular to the course, so that I can calculate when the Start/Finish line is crossed.   Given my "concerns" with the GPS signal, my thought is to use another PRO MINI to handle the GPS and have it send only the specific data to the MEGA.  Idealy I'd like to "query" the GPS, rather than have it send data asynchronously, though that does not seem possible with any of the shields available for GPS units.
Pages: 1 ... 3 4 [5]