Show Posts
|
|
Pages: 1 [2] 3 4 ... 146
|
|
18
|
Using Arduino / Programming Questions / Re: [Solved] led bar code simplify
|
on: May 17, 2013, 12:45:39 pm
|
digitalWrite (ledbar1[0], (a0c>i)); This does both the turning on and turning off... a0c>i returns true or false. True is 1, false is 0. HIGH is 1, LOW is 0. So it either turns the LED on (a0c > i) or it turns it off (a0c <= i). So, if a0c is 2, the results are: i=0, a0c > i, 2 > 0, TRUE, LED On i=1, a0c > i, 2 > 1, TRUE, LED On i=2, a0c > i, 2 > 2, FALSE, LED Off i=3, a0c > i, 2 > 3, FALSE, LED Off
|
|
|
|
|
19
|
Using Arduino / Programming Questions / Re: led bar code simplify
|
on: May 17, 2013, 07:52:12 am
|
The trick is to look at things that repeat with only small changes. In your code the following block is repeated with just a change of number: if (a0c==1 || a0c>0)digitalWrite (ledbar1[0], HIGH); else digitalWrite (ledbar1[0], LOW);
Replace those static numbers with a variable generated by a for loop, and you only have the block once. eg: for (unsigned char i = 0; i < 4; i++) { if (a0c>i) digitalWrite (ledbar1[i], HIGH); else digitalWrite (ledbar1[i], LOW); }
|
|
|
|
|
20
|
Using Arduino / Programming Questions / Re: How to save 9600 port to text file
|
on: May 17, 2013, 07:47:33 am
|
|
Please clarify:
Do you want to:
a) Read data being sent by an Arduino using your PC, and save it to a text file on your hard drive, or b) Read data being sent by some other device using an Arduino, and save it to a text file on an SD card?
The two things are radically different, so we need to know what you mean.
|
|
|
|
|
22
|
Using Arduino / General Electronics / Re: Low Pass Filter for Serial
|
on: May 16, 2013, 10:59:04 am
|
Right - it sounds like after demodulation you will have a serial signal. However, "serial" is a very generic term. Most of the time people say "serial" when they mean "rs-232", so connecting it to the RX input of the Arduino's serial port might work. If it is rs-232 they should have provided you with baud rate and byte format (8-N-1 is most common - 8 bits, no parity, 1 stop bit, but it could be anything really). The simplest demodulator is an envelope detector - this is basically what was used in early AM radios. The output of the envelope detector may need some cleaning up before entering the Arduino to get it to the right levels - maybe a simple Schmitt Trigger buffer may be all that's needed.
|
|
|
|
|
23
|
Using Arduino / General Electronics / Re: Low Pass Filter for Serial
|
on: May 16, 2013, 09:51:03 am
|
(and seem a little too secretive) That's often the case... Have you signed an NDA? i was thinking to ask the company to provide me with a Tektronix Oscilloscope. I think they have the 2225 model (50 Mhz). Would that help with this building process or is this not worth asking for?
A scope is one of the basic pieces of equipment all proper EEs should own. I have a rather aged OS-9020A analogue scope (it was free). I could do with a decent digital one to complement it too. I prefer a proper analogue one for working with analogue signals, but you can't beat a digital one for working with digital signals - analysing protocols etc. I use my scope daily - I think more than my DMM.
|
|
|
|
|
24
|
Using Arduino / General Electronics / Re: Low Pass Filter for Serial
|
on: May 16, 2013, 09:11:26 am
|
|
Also there is the underlying data encoding to worry about - is it a straight serial signal, or is it something like a manchester coding, or 8b10b, or what? Without those kind of details it's not possible to do your job.
|
|
|
|
|
26
|
Using Arduino / General Electronics / Re: Low Pass Filter for Serial
|
on: May 16, 2013, 07:28:26 am
|
|
Ok. So is the signal a lower-frequency digital signal encoded into a higher frequency analogue carrier wave? Kind of like a radio signal? If so you will need to de-modulate the signal, and for that you will need to know the modulation technique used - AM, FM, PSK, FSK, ASK, QPSK, etc...
Do you have a data sheet available for the device that is generating the signal?
|
|
|
|
|
27
|
Using Arduino / Programming Questions / Re: serialEvent function, Interrupt driven or not?
|
on: May 16, 2013, 07:12:12 am
|
serialEventRun() is called after every loop, but it then checks the availability of serial data and calls the serialEvent() function only if needed: void serialEventRun(void) { #ifdef serialEvent_implemented if (Serial.available()) serialEvent(); #endif #ifdef serialEvent1_implemented if (Serial1.available()) serialEvent1(); #endif #ifdef serialEvent2_implemented if (Serial2.available()) serialEvent2(); #endif #ifdef serialEvent3_implemented if (Serial3.available()) serialEvent3(); #endif }
|
|
|
|
|
28
|
Using Arduino / General Electronics / Re: Low Pass Filter for Serial
|
on: May 16, 2013, 06:14:44 am
|
|
As the others have stated, what you ask makes no sense.
So, please furnish some more information, as what you are trying to do is either badly described (so we don't understand it), or you are going about it all the wrong way.
1. What is this mystery 8MHz signal? 2. What do you want to actually do with it?
I'm asking for high level stuff here. Not "I want to read it with the serial port", but "I want to do tell if it's pink, or if it's cheese flavoured".
|
|
|
|
|
30
|
Using Arduino / Programming Questions / Re: serialEvent function, Interrupt driven or not?
|
on: May 16, 2013, 05:27:59 am
|
In main.cpp in the arduino core: int main(void) { init();
#if defined(USBCON) USBDevice.attach(); #endif
setup();
for (;;) { loop(); if (serialEventRun) serialEventRun(); }
return 0; }
As you can see from that, any serial events are processed at the termination of each iteration of the loop() function. It's not interrupt driven. You can only reliably use the serial events if your loop() function doesn't run for too long (and certainly not if loop() never returns), so never ever use delay() unless you have modified your system to give the serial system a huuuuuge buffer.
|
|
|
|
|