Show Posts
Pages: 1 2 3 [4]
46  Forum 2005-2010 (read only) / Interfacing / Re: custom baud rate in serial monitor? on: February 28, 2009, 11:11:15 pm
Can you use Hyperterminal or some other terminal program? Does it have to be the serial monitor?  If you havent played with this its easy, just exit the Arduino environment then start Hyperterminal.  

Ocasionally you may have to unplug the Arduino, when you switch back to the development environment to reset things.  Just make sure you dont try to run Hyperterminal and the development tool at the same time....

It looks like Hyperterminal only suppports 230k, but this may work OK.  The Arduino uses the identical registry settings for 230400 and 25000.  Its sure worth trying.
47  Forum 2005-2010 (read only) / Interfacing / Re: read output of dc motor on: January 28, 2009, 09:45:15 pm
Thanks for the voltage protecton tutorial.

You are right about the second zener.  I got my wires crossed....
48  Forum 2005-2010 (read only) / Interfacing / Re: read output of dc motor on: January 27, 2009, 10:28:41 pm
You could do a diode bridge (4 diodes - see wikipedia).  That would give the same voltage either direction, but no indication of which direction.  

So (check me guys) couldnt you
1) voltage limit with a 5 volt zener to ground from each side of the motor.  seems like a good idea anyway.  
2) use a diode bridge to an analog pin.  
3) detect direction by running each zener protected side of the motor directly to a digital pin.  Of course it would only show direction when the voltage reached logic high.  
49  Forum 2005-2010 (read only) / Interfacing / Re: Can an Arduino send a dialup email message? on: January 18, 2009, 10:32:57 am
I used to use external modems to send numeric pages when servers went down.  It is trivial to use the modem AT commands to send any touchtone sequence.  All you would need to do is level shift the TTY serial to RS232 direct to the modem.  Dont start a data connection, just emulate a user with a touchtone phone.

I dont know how the current text services work, is there a way to send text messages or e-mail from an ordinary touchtone phone?  If so, you should be able to do anything you could do with a touch tone phone wit AT command REALLY easily.

Also, I dont know for sure how muc current the external modems draw, but it is probably a lot more than the Arduino.  Dont think you can run this on a 9volt for more than a couple of minutes.  May be a pack of rechargable D cells or a burglar alarm lead acid battery.
50  Forum 2005-2010 (read only) / Interfacing / Re: circuit for automatic air organ on: January 18, 2009, 09:33:19 pm
The schematic shows an NPN transistor.  If you want to put the solenoid between the transistor and power use a PNP transistor (though that will be turned on with a "0" output).  That swaps the position of the emitter & collector in the circuit.

To way oversimplify, the rule of thumb is to always put the load on the collector side of the transistor.  If the load is on the emitter, it can change the voltage the emitter "sees" and cause erratic behavior.  If you put it on the collector side, then you are OK as long as the base and emitter voltages have the right relationship.  

I agree the transistor doesnt need to be huge.  I use PN2222/PN2907 (small switching transistors) for relays and have no problems with heat.   Using too small of a base resistor is going to burn them up easier than too much load.

"Electrical Engineering 101 - everything you should have learned in school but probably didnt" by Darren Ashby has the best intuitive explanation of this that I have ever seen.  Unfortunately the last third of the book is how to deal with engineering managers.....
51  Forum 2005-2010 (read only) / Interfacing / Re: Any chance serial drops zeros? on: January 23, 2009, 08:32:10 pm
Thanks vputz
If you get a chance to try this for a test I would be really curious what you find out.  I tested with a dead short, so it will be interesting to see how a more realistic failure looks.

I posted in the software section for how to code this "legally"; or if it would be a candidate for a core change.   I think the best "legal" way to do this is to essentialy copy the wiring_serial library to a new name say "test_serial" with new function names.   Then as long as you only used functions from the new library, the orignial library should not link.

Only problem is, I cant figure out how to make it compile when I do the rename.
52  Forum 2005-2010 (read only) / Interfacing / Re: Any chance serial drops zeros? on: January 22, 2009, 10:46:15 pm
Kluge to check for serial receive errors -- seems to work on my bench top....

the status byte is ORed with the new status after every each character is received.  When you check the status after receiving a number of bytes, if the error bits are not set, then there were no errors.  If there were errors at any time since the previous status check the error bits will be set.  This is much faster than checking for errors after every byte and shouldnt throw off buffering too much.
The routine to read the status register resets the variable to 0 each time it is called.

Finally -- only bits 2-4 indicate errors. I mask them in the test program.  
**********************
NOTE this involves editing the wiring serial library.  Not something you want to do for your production code.   I dont know the "official" warnings on this, but be sure you make backup copies so you can put the original files back.

I am still researching the "correct" way to do this, and this shouldnt cause any problems as long as you put the original files back.
**********************

Part 1 - Edit wiring_serial.c
Code:
// this stuff is near the top of the files
int rx_buffer_head = 0;
int rx_buffer_tail = 0;
//  ********begining of first change*******
// new status variable here
byte status_reg = 0;

//function to return status byte
//status variable reset to 0 with each call
int serialStatus(void)
{
  int temp;
  temp = status_reg;
  status_reg = 0;
  return temp;
}
//  ******end of  first change*********
void beginSerial(long baud)

//**** second change ***********
//  skip further down the file to make this change
//  modify the interrupt/signal routine
// ****************************
#if defined(__AVR_ATmega168__)
SIGNAL(SIG_USART_RECV)
#else
SIGNAL(SIG_UART_RECV)
#endif
{
#if defined(__AVR_ATmega168__)
      unsigned char c = UDR0;
#else
      unsigned char c = UDR;
#endif
// ************ begin second change *********
//get status byte
               status_reg = status_reg | UCSR0A;
//************  end second change  **********
      int i = (rx_buffer_head + 1) % RX_BUFFER_SIZE;

      // if we should be storing the received character into the location
      // just before the tail (meaning that the head would advance to the
      // current location of the tail), we're about to overflow the buffer
      // and so we don't write the character or advance the head.
      if (i != rx_buffer_tail) {
            rx_buffer[rx_buffer_head] = c;
            rx_buffer_head = i;
      }
}


Part 2 -- edit wiring.h
Code:
// you should problably put this near the other serial declarations
int serialStatus(void);

Part 3 -- Demo program
Code:
// reads a serial character then echos it back
// checks the status byte before each read
// you really should only check status at the end of a packet
// the delays are probably not necessary
int read_char;
int status;
void setup()
{
  Serial.begin(9600);
  
  // prints title with ending line break
  Serial.println("Serial Test");
 
  // wait for the long string to be sent
  delay(100);
  
 // pinMode(ledPin, OUTPUT);
  
}


void loop()
{
  if (Serial.available() > 0)
  { status = serialStatus();
// only bits 2-4 indicate errors  mask the others with 0x1C
// bit 2 = parity
// bit 3 = data overrun
// bit 4 = frame error
    status = status & 0x1C;
    read_char = Serial.read();
    Serial.print("*");
    Serial.print(read_char, BYTE);
    delay(100);
  }
 else
   {delay(25);}
 
 if (status != 0)
  {Serial.print("#");
   Serial.print(status);
   Serial.print("#");
  }
}
53  Forum 2005-2010 (read only) / Interfacing / Re: Any chance serial drops zeros? on: January 21, 2009, 11:38:35 pm
Hey vputz
 I got a test routine that will report errors on the UART running.   First cut is NOT pretty - requires editing the wiring serial file.
However it is only about 10 lines of code.  

There HAS to be a better way to link this, but as a quick test it seems to work.  I have tested by grounding the RX line while dumping data from Hyperterminal and it definitely throws an error.....  

No time tonight to upload, but I will get this posted tomorrow.   I am also going to try to figure out a clean way to do this as a separate library rather than editing wiring.  
54  Forum 2005-2010 (read only) / Interfacing / Re: Any chance serial drops zeros? on: January 19, 2009, 08:48:24 pm
Point granted on the stop bit timing.

I just went through wiring_serial.c and it doesnt seem to check the error bits.  I am looking at whether I can easily chain to it and check for error codes at each character.  That would increase the odds of a buffer overflow so you wouldnt want to leave it turned on, but it would be good for testing this type of problem.

If you did have bad or mismatched hardware, the framing errors should pop right out.
55  Forum 2005-2010 (read only) / Interfacing / Re: Any chance serial drops zeros? on: January 18, 2009, 11:53:10 pm
I agree that trying other baud rates is a good idea (and the most likely issue)  The AVR data sheet is pretty readable. andshows 9600 and 4800 at .2% error but 2400 at -.1%,  
and 115.2K at -3.5%....

--- nit picking discussion of serial timing follows
That said, repeated Nulls really is a degenerate case.   Even if your baud clocks are perfectly matched  if the delay between characters is close to one bit time (maybe even up to 11 bit times) the pattern really is ambiguous.   As I recall the UART doesnt control that delay either, its just that software usually takes a few clock cycles between character writes.

<wordy story about HP pen plotters and vt100 emulators deleted>

In any case this should cause an error on the UART because the stop bit wont be in the right place (there wouldnt be a stop bit).  The AVR datasheet shows the UART error codes in the UCSRnA. register, but it looks like it gets cleared with each character read.  You might be able to look in the Arduino source and see if they check for errors in that register in the serial routines.   Or it might be interesting to grab the UART interrupt and service it in your own code that way you could check for frame errors.  

If you have time to execute code betweek incoming characters you might be able to read the UCSRnA register yourself, but you would have to read it before the next char comes in.

A serial debug tool might be handy if someone would code it...allow all the serial parameters to be set. There is good autobaud code out there, how about something to identify unknown serial speeds......
56  Forum 2005-2010 (read only) / Interfacing / Re: Any chance serial drops zeros? on: January 18, 2009, 07:49:53 pm
Assuming you are dropping 0x00 bytes not ASCII "0" bytes, this problem is likely regardless of your hardware.  The serial character is sent as:
space, 8 bits, mark    that is:
0, 0000000, 1

The line then stays at 1 until the next character.  if you send these very close together the mark time is approximately 1 bit.  There is no way to determine if the "mark" - 1 is a mark bit or a "1" in the middle of a data byte.  If it looks like it is in the middle of a data byte, it will be discarded as an error since there will not be a mark at the end of the word.

Anyway, if you are not using parity bits, then sometimes you can slow down the transmitting machine.  Older systems would sometimes let you specify an "intra character delay" (or something of the sort).  What you need is to make sure you never get characters closer together than 10 or 11, bit times, that way the start of the next character is always clear.   Parity check or a packet length/parity check would be best.

I have had this trouble sending from a PIC to my PC if I set characters at maximum speed with no delays.  I was sending two repeating characters at maximum speed.   The PC would sync up in the middle of the character and display two different characters.  If I plugged and unplugged the cable, eventually it would start on the right bit boundary and display properly.

57  Forum 2005-2010 (read only) / Interfacing / Re: Questions about transistors, capacitors and diodes on: January 22, 2009, 09:57:20 pm
You can use two bipolars to make a pseudo darlington.  But I dont think you can easily substutue a darlington for a bipolar.  

58  Forum 2005-2010 (read only) / Interfacing / Re: Questions about transistors, capacitors and diodes on: January 21, 2009, 10:28:02 pm
The 3904 and 3906 are a NPN/PNP pair  with similar characteristics.

If you go with the 2N2222A, you should get a 2907 for the PNP.  I use the 2222/2907 type for my "generic" transistors.  You dont seem to have a higher current PNP on your list.  

You dont want to find out that your NPN and your PNP take different base resistors (different base current).  That will make substitution that much harder...

59  Forum 2005-2010 (read only) / Interfacing / Re: Multiple LED drivers power problem on: January 18, 2009, 09:37:10 pm
Just a starting point, but make sure all the 4794s have good power and ground.  Chips #2 and #3 might be getting power or ground from the daisy chain, not from the board.  If the board wasnt providing enough current, then should all be dim.
Pages: 1 2 3 [4]