Show Posts
Pages: 1 ... 73 74 [75] 76 77 ... 153
1111  Community / Gigs and Collaborations / Re: Arduino Single Channel Logic Analyser on: March 27, 2013, 12:17:26 pm
For your PC client have a look at SUMP
I think it will do what you want, all you have to do is spit out the data in the right format.
I have seen SUMP but not keen to run it as it need Java console.
1112  Community / Gigs and Collaborations / Re: Arduino Single Channel Logic Analyser on: March 27, 2013, 08:52:20 am
The problem is that you manipulate individual bits.  captureMode has to be fetched, altered, and then stored when you change a bit.  The risk is that an interrupt occurs after fetch but before store.  At that point the value stored may have been poisoned.
I think the only unprotected code now is when the capture is turned off so the ISR is only reading captureMode and not altering it.
1113  Community / Gigs and Collaborations / Re: Arduino Single Channel Logic Analyser on: March 26, 2013, 04:08:17 am
captureMode has to be protected by a critical section in loop.
I've hopefully protected captureMode where it counts now. I figure there is less need to protect when capture not active as ISR does not access anything but captureMode and it's byte size so will never get interrupted half way though storing a byte (I hope).
bufferWrite probably has to be protected by a critical section.
bufferRead probably has to be protected by a critical section.
Done.
This...
Code:
   if (noiseThreshold > 0){
      if (microDiff < noiseThreshold){                      // Pulse to short?
        return;                                             // Yes, so drop out now
      }
    }
...may be useless and could cause problems.  I believe the hardware that detects CHANGE already has noise suppression.
Believe it or not I get lots of little spikes without it set to something like 50 (default) but the main reason for having this is so reading a device like an analogue RF receiver that could exhibit noise when not receiving a signal I can suppress false readings by adjusting it.

Code:
       //noInterrupts();
        noiseThreshold = (unsigned long)cmdData;
        //interrupts();
...any particular reason you comment-out those two important lines of code?
In debugging I must have commented them out but forgot to put them back in, thanks.

Code:
 Serial.begin(57600);                                      // Fast(ish) Serial
...250000, 500000, and 1000000 are better choices for the baud rate.
Now 115200
I currently use freeMemory to show how much RAM is spare so I can eventually tweak the buffer size but I really need to know if things like the stack are dynamic and can grow into the free memory or does it have a fixed space not included in the freeMemory result. This is so if I increase ringBuffer so only 20 or so bytes remain will the stack or Serial grow into this space and corrupt?

EDIT: Added sketch
1114  Community / Gigs and Collaborations / Arduino Single Channel Logic Analyser on: March 24, 2013, 01:10:41 pm
I have this idea that an arduino could be used as a simple logic analyser. People without such toys asking on here for help decoding  IR remote, Serial or RF transmitter data could be asked to load a sketch, attach the device and grab some data that can be used to decode/debug.
As the arduino has very little memory I figure the best way to sample data is to grab pin transition times instead of taking a sample every x micro seconds. Store the time in a circular buffer so you can start serial printing the data out ASAP while still capturing, to further extend the capture duration.
I have started on some arduino code and it seems to be working okay (still debugging it) but now the data needs displaying on the computer and this is where I'm hoping someone else will be willing/able to help.
I figure the best option to make the PC code is to use something like Processing as it's free and works on Windows, Linux & Mac.
Does anyone think this is a good idea and is willing to write/help write the processing code to realize the idea.

Attached is an idea of what the Processing output should look like though it would be single channel only. It would need ability to zoom in/out and maybe measure time between 2x user movable cursors.
Also attached is a sample dump of the serial data from this capture session. Each number is the approx duration in milliseconds since the last transition and bit zero of this number denotes if the signal is high/low (1=high, 0=low)

This is unpaid as I want the code to become public domain.

EDIT: Added current Arduino code

 
1115  Using Arduino / Programming Questions / Re: Pointers on: March 23, 2013, 06:42:48 am
Looks like it should be fine - have you tested it? What are your results?
I have not tested it yet. I'm about to embark on learning processing (deja-vu with the PDE interface) to display the data as it seems the most suitable cross platform graphics engine I can find.
1116  Using Arduino / Programming Questions / Re: Pointers on: March 23, 2013, 06:17:09 am
Sorry for the late reply, I some how missed it.
I could not get your example to compile but altered it so it did compile but will it work as I hope?
The sendRingBuffer should serial write just one entry (long converted to 4 seperate bytes) per call.
Code:
byte sendRingBuffer(){
  if (bufferRead != bufferWrite){                           // Data in buffer?
    Serial.write((uint8_t *)ringBuffer[bufferRead], sizeof(long));
    bufferRead++;
    if (bufferRead >= bufferSize){                          // End of buffer?
      bufferRead = 0;                                       // Reset back to start of buffer
    }
    return true;                                            // Signal data written
  }
  return false;                                             // Signal no data written
}
1117  Using Arduino / Project Guidance / Re: Receive Pelco commands from cctv system, move servo's on: March 23, 2013, 03:53:04 am
Right, i've found there are RS485 shields available, in america it seems so far, but i'll keep looking for a uk supplier... tho TBH it does look pretty simple to make my self.
Hobbytronics have the Sparkfun RS485 http://www.hobbytronics.co.uk/components/breakout-boards/rs485-breakout I have ordered stuff from them several times and had no problems.
Proto-Pic is another UK supplier that has the same item http://proto-pic.co.uk/rs-485-breakout/
CoolComponents  is another UK supplier of decent stuff though a quick search did not find RS485.
And if your prepared to maybe wait a bit there is always eBay
1118  Using Arduino / Project Guidance / Re: Building a Spring Tester on: March 22, 2013, 10:28:28 am
Quote
Riva: That motor would be perfect - I thought it was, actually, until I was informed that some of our spring configurations would require such high force. Thank you for the suggestion.
Did you do the calculation to take into effect the 30:1 gearbox or just the 3.1Nm motor. Google and you will find various CNC motor/gearbox configurations ranging from 30 to 600 Nm and ball screw shafts in metric.
1119  Using Arduino / Programming Questions / Re: Pointers on: March 22, 2013, 07:20:53 am
Do you want to output the actual values as human readable text, or just dump the content of the array as raw binary data?
Raw data, I'm trying to make a simple logic analyser so need to empty the ring buffer ASAP (raw = less data than ASCII representation of number) to give longer data runs before buffer overflows.
1120  Using Arduino / Programming Questions / Pointers on: March 22, 2013, 07:15:05 am
I have hit a stumbling block with my old nemesis pointers.
I have an array defined as unsigned long's and  I want to write a values from this buffer to serial. I figured I could do this using Serial.write(buf, len) and have buf as a pointer to the data in the array and len=4 for the 4 bytes of the unsigned long.
Is this possible and if so how, or do I have to do 4 separate Serial.writes using rotate and mask.
Below is cut down code of what I want to do with the offending Serial.write line remmed out so I could check the rest of the code compiled okay.
Code:
#define bufferSize 256        // bufferSize is the size of the ring buffer
// Ring (Circular) Buffer
volatile int bufferRead = 0;                                // The head of the buffer
volatile int bufferWrite = 0;                               // The tail of the buffer
volatile unsigned long ringBuffer[bufferSize];              // The buffer

void setup(){
  Serial.begin(115200);                                     // Fast Serial
}

void loop(){
  sendRingBuffer();
}

byte sendRingBuffer(){
  if (bufferRead != bufferWrite){                           // Data in buffer?
    //Serial.write(&ringBuffer[bufferRead],4);  //<< HERE IS THE PROBLEM
    bufferRead++;
    if (bufferRead >= bufferSize){                          // End of buffer?
      bufferRead = 0;                                       // Reset back to start of buffer
    }
    return true;
  }
  return false;
}
1121  Using Arduino / Project Guidance / Re: Building a Spring Tester on: March 22, 2013, 03:49:33 am
To get your 0.005mm resolution with a standard 1.8 degree stepper motor the ball screw would need to be 1mm pitch or less. If you fit a gearbox to the setup then the pitch can be increased and/or the measurement resolution increased.
You did not specify a budget but this motor has a 30:1 gearbox so using a 10mm pitch ballscrew would mean each step would be about 0.00166mm.
 
1122  Using Arduino / Programming Questions / Re: Search order for include files on: March 21, 2013, 06:45:16 am
Thanks.
1123  Using Arduino / Programming Questions / Re: Search order for include files on: March 21, 2013, 06:03:08 am
Thanks for the reply PaulS,
Quote
If I put this library in the recommended library folder
If, by that, you mean the libraries folder in the sketch directory, then you will have problems, having two LiquidCrystal libraries.
Yes that's what I meant.
If, by that, you mean replacing the LiquidCrystal library delivered with the IDE, then you won't have a problems, since you'll still only have one LiquidCrystal library.

The issue lies not in search order. It lies in the fact that both libraries folders are searched, and there is no stopping when a particular library is found. The rest of the current folder is searched as well as the other folder.
Okay, so it searches all the folders but where will it pluck the final library from? Will it error because both are present or pick the first/last one found. Does using <> instead of "" to enclose the library name effect where the library is searched?
1124  Using Arduino / Programming Questions / Search order for include files on: March 21, 2013, 05:44:41 am
I have just come across this code that has an improved version of the standard LiquidCrystal library. If I put this library in the recommended library folder then will it be used instead of the built in one when I include it using #include "LiquidCrystal.h" or will this pick up the build in version.
Also will any old code that uses #include <LiquidCrystal.h> still pick up the built in code?
1125  Using Arduino / General Electronics / Re: How to show internal pullups on a schematic? on: March 21, 2013, 05:12:09 am
My opinion is to put a resistor on the schematic then the circuit will look/be correct. The person building the end product from this circuit could either fit these external pullups or omit them and use the internal ones. Even if you make the PCB from the schematic you have the resistor pads but just leave the resistor out and turn on internal pullups.
Pages: 1 ... 73 74 [75] 76 77 ... 153