Loading...
  Show Posts
Pages: 1 ... 426 427 [428] 429 430 ... 473
6406  Forum 2005-2010 (read only) / Interfacing / Re: intercepting rs 485 communication on: January 12, 2011, 07:51:35 pm
Quote
it seems the 485 bus is not the one communicating with the heating controller, so I would not be able to send any info to the wireless receiver or the controller.
I'm confused now, can you post a drawing showing what talks to what?

Re the schematic, I assume this is a functioning 485 link that is already properly terminated, so you shouldn't need to add your own 150R resistor.

Quote
and can see on my scope that there are things happening
Are you referring to the RX_PIN signal? Is the bit rate correct? Does it look like proper async serial characters? Is the polarity correct?

______
Rob

6407  Forum 2005-2010 (read only) / Interfacing / Re: intercepting rs 485 communication on: January 12, 2011, 09:44:13 am
You can connect your own 485 transceiver to the line and pretend your gadget is a "receiver", however

  • You're going to have to write some code to implement their protocol.
  • You may have to disconnect the existing receiver (that depends on the protocol).
_____
Rob

6408  Forum 2005-2010 (read only) / Interfacing / Re: Need help with Relays not switching back. on: January 12, 2011, 07:39:05 pm
Quote
GND the Collector of the transistor
That sounds a bit strange, as before how about a schematic.

Quote
the relay just switches back and forth, does anyone know why?
Sounds like you've built a buzzer buy having the coil power passing through one of the contacts. Once again, post the schematic.
_____
Rob

6409  Forum 2005-2010 (read only) / Interfacing / Re: Need help with Relays not switching back. on: December 18, 2010, 10:13:36 pm
Quote
Arduino Pin 13 --> 1k R --> Transistor Base
5v External Input --> Transistor Collector
Transistor Emitter --> Relay Coil

Roddiy

This is not the circuit everyone has been trying to describe and not the one in the playground PDF that you say you're using. Which is correct? The text description above will not work.

______
Rob

6410  Forum 2005-2010 (read only) / Interfacing / Re: Need help with Relays not switching back. on: December 18, 2010, 07:39:23 am
Quote
Sorry i meant Transistor Emitter --> Relay Coil
Did you mean that?

Anyway if you have the circuit as per that drawing there's no way it won't turn off if the Arduino pin is low.

We gotta see your code, and remember that some transistors have different pinouts so it's easy to put them in backwards.

______
Rob

6411  Forum 2005-2010 (read only) / Interfacing / Re: Simultaneous Serial Communication USB + TX/RX  ??? on: January 12, 2011, 05:03:18 am
Quote
Complex.

Honestly I don't think this is a complex problem, but the reason we've suggested about 10 different methods is I don't think we know exactly what needs to be done.

The worst case is a full duplex link between all three devices

PC -> RX Ard1 TX -> RX Ard 2
PC <- TX Ard1 RX <- TX Ard 2

Where the Ard1/PC link is the standard hardware serial port and the Ard1/Ard2 link is a software serial link.

Quote
three digital ports or three analog ports on both machines and communicate in 8 bit for now
I've lost you there, why three pins? and all comms will be 8-bit anyway.

Also as I said before, what part of your project has outgrown a single Arduino? If we know that we may be able to suggest an even simpler method.

______
Rob

6412  Forum 2005-2010 (read only) / Interfacing / Re: Simultaneous Serial Communication USB + TX/RX  ??? on: January 11, 2011, 07:13:42 pm
It's not entirely clear (to me at least) if you want to talk both ways on both links.

If so then you can't do it without extra hardware and even then not "simultaneously".

However if you are just sending data "upstream" to the PC you can do it

PC <- Ard1 TX -- Ard1 RX <- Ard2 TX

However you would need to break out the RX pin on Ard 1 as this is connected to the USB circuit on the PCB.

Another option is to leave the USB connection alone and use SoftwareSerial to talk to the second Arduino (in which case you can talk both ways on both links).

Having said that, why do you need a second Arduino? It would be much easier to use a larger one or maybe an IO expander.

______
Rob

6413  Forum 2005-2010 (read only) / Interfacing / Re: DC Current Sensor on: January 11, 2011, 06:49:19 pm
There are also high-side measuring chips such as

AD8210/2/3
INA138/139/169...
MAX4080/1

etc.

All these are designed to handle high voltage on the sense resistor but work on 5v logic.

______
Rob

6414  Forum 2005-2010 (read only) / Interfacing / Re: Missing counting encoder on: January 11, 2011, 01:45:29 am
Hi YeahYoo,

We need to know the answers to Richard's questions, ie rotational speed and position or just RPM needed.

However, bear in mind that interrupts are actually slower than properly-written polled code, so if the speeds are high you may need to adjust your code.

______
Rob

6415  Forum 2005-2010 (read only) / Interfacing / Re: timer interrupts - how to set the frequency on: January 08, 2011, 08:39:16 pm
Quote
Is there a bit of documentation that explains what all the cryptic acronyms mean?
The standard AVR docs, see here

http://atmel.com/dyn/products/product_card.asp?PN=ATmega168PA

The acronyms are a bit daunting at first, but it gets easier.

______
Rob
6416  Forum 2005-2010 (read only) / Interfacing / Re: timer interrupts - how to set the frequency on: January 08, 2011, 11:26:42 am
I haven't checked your bit patterns for the timer setup but

16,000,000 / 1024 / 256 = 61Hz

If you toggle an OP each interrupt you get 30Hz.

You will have to

a) Use a smaller prescaler and
b) Use the output capture interrupt instead of the overflow.

______
Rob

6417  Forum 2005-2010 (read only) / Interfacing / Re: Double Interrupt on PPS on: January 07, 2011, 04:25:42 am
Volatile basically means that "things" may change the variable in a manner that's not obvious when the compiler looks at the code. Such as say a input register that changes state when inputs change. To quote from the Netrino site

Quote
C's volatile keyword is a qualifier that is applied to a variable when it is declared. It tells the compiler that the value of the variable may change at any time--without any action being taken by the code the compiler finds nearby.

Frankly I don't know why it should be required in your exact code because the compiler should know what's going on, and as it's working maybe that is in fact the case. Still, it's good practice to use the qualifier for vars shared with ISRs.

One place this will bite you is with optimisation

Code:
loop () {
   long i;

   for (i = 0; i < 100; i++ ) {
       i = i;
   }

   pulse_pin ();

}
In this simple loop I am just trying to output some pulses to see some timing for whatever reason and I want to vary the loop time by changing the 100. But no matter what I change it to, even 1,000,000 the frequency of the pulse stays the same.

The compiler has decided that the loop actually doesn't do anything and has removed it from the run time code. Changing it to

volatile long i;

fixes the problem by causing the compiler to butt out.

Quote
wouldn't another if statement inside of the for loop add greater overhead?
Yes but there's plenty of fat because of the delay, so adjust the

delayMicroseconds(1931);

to accomodate the extra code in the loop.



______
Rob

6418  Forum 2005-2010 (read only) / Interfacing / Re: Double Interrupt on PPS on: January 06, 2011, 07:07:31 pm
You could do it a little bit simpler

Code:
       for (int i = 0; i < 49 ; i++) {
              digitalWrite(pinout, HIGH);
                delayMicroseconds(50); //50us wave
                digitalWrite(pinout, LOW);
                if (i < 48) delayMicroseconds(1931); // tweak for correct pulse spacing
         }

Also you still don't have the volatile on ppsStart.

______
Rob

6419  Forum 2005-2010 (read only) / Interfacing / Re: Double Interrupt on PPS on: January 06, 2011, 11:00:44 am
The volatile is no longer necessary because you aren't accessing "time" in the ISR, but for future reference

volatile unsigned long time = 0;

would do and leave it as a global where it is.

Here's a simplified version of the main loop

Code:
 if(ppsStart == true) {
        ppstart = false;
        delayMicroseconds(35); //A necesary ofset I need to be able to adjust
        for (int i = 0; i < 50; i++) {
              digitalWrite(pinout, HIGH);
                delayMicroseconds(50); //50us wave
                digitalWrite(pinout, LOW);
                delayMicroseconds(1940); // tweak for correct pulse spacing
         }
  }

Which I think is about right although it's late here and I'm falling asleep at the keyboard  smiley

This version however uses delays and so does not allow for the loop to do anything else while the pulses are being generated.

______
Rob

6420  Forum 2005-2010 (read only) / Interfacing / Re: Double Interrupt on PPS on: January 05, 2011, 07:48:42 pm
I haven't fully analysed the code but

Code:
void loop()
{
  if(micros() - time > 2000 && ppsStart == true) //this gives me a 50us pulese every 2ms
  {
    time = micros();
    [glow]digitalWrite(pinout, HIGH);
    delayMicroseconds(50);
    digitalWrite(pinout, LOW);[/glow]
    pulseCount++;
    if(pulseCount > 400) //runs 400 times so to notoverlap the next second
    {
      ppsStart = false;
    }
  }

}

void pulsein() //interrupt routine and a single 50us pulse
{
  time = micros();
  [glow]digitalWrite(pinout, HIGH);
  delayMicroseconds(50);
  digitalWrite(pinout, LOW);[/glow]
  ppsStart = true
  pulseCount = 1;
}


You have a pulse in the ISR and also in the main loop. That's the two you are seeing.

Having read further, your problem is that you only get 1 pulse not 400. Is that the case?

I'd ditch all the ISR code for starters

Code:
void pulsein()
{
  ppsStart = true
}

then look at why the loop isn't working right.

gardner says:
Quote
"time" is handled in both the main loop and ISR.  It must be "volatile".
DOH! Can't believe I didn't see that  smiley
______
Rob

Pages: 1 ... 426 427 [428] 429 430 ... 473