Display filtered data

Go To Last Post
18 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi everyone! I'm a new in all these avr microcontrollers things, but i'm trying to make a notch filter on atmega8515.

I would like to know, how to display all the filtered data  on my terminal screen.

Do i have to create a string to display them?and if yes,how?

Thanks a lot!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

First up, you google avr-gcc stdio
There should be plenty of hits to tell you how to set up the usart and printf.

Then decide how you want to format the data. Comma separated hex values?

The whole thing would be easier if you get a cheapy Arduino board and side step all the usual problems getting this stuff working.

How many samples per second do you want to output?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'd be looking at what kind of display YOU want to show. Then work back from there to determine how to achieve that.

 

Do you want to just show comma separated values as Kartman suggest:

0x17, 0xB3, 0x2A, 0x57, 0x5E ...

Or are you aiming for something "fancy":

 

https://s3.amazonaws.com/fp.strategy11.com/images/knowledgebase/graph_type-examples.png

 

or more likely:

 

https://www.diyaudioandvideo.com/Calculator/SeriesNotchFilter/Help/graph2.gif

 

There'll clearly be more work achieving the latter but it may make it easier to analyse the data.

 

There are no doubt "half way points" between these two:

 

                *
               *  *
               *  *
              *    *
              *    *
              *    *
              *    *
             *      *
            *        *
           *          *
         *              *
       *                  *
       etc.

That's a "sort of graph" but actually created by sending just asterisks to a terminal.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Best solution is to convert your values (they are integers) into null terminated string  numbers, and then, to send them on the serial line.

On the PC side, thousands of softwares can capture these values, and import them into excel, put them into a *.csv file , display nice graphs...

 

Let us remain on the avr side : you should have a serial -USB adapter, and a terminal program on your PC to check your software.

Bray's terminal seems very appealing  https://sites.google.com/site/te... as it can display nice curves ...

 

But, on avrside:

for sending a null terminated string http://www.github.com/abcminiuser/avr-tutorials/blob/master/USART/Output/USART.pdf?raw=true explains how to set up a serial line (BTW: your avr needs a Xal oscillator)  and the function "puts " does all the job

http://www.atmel.com/webdoc/avrl...

examples such as https://appelsiini.net/2011/simple-usart-with-avr-libc/ seem easy to read/adapt for me...

 

(you should begin by trying to send , say, "hello world" for your avr to see if your PC terminal  can read it and dsiplay it).

 

for conversion (8515 is RAM limited, I fear) you should look at http://www.nongnu.org/avr-libc/u... to convert an integer into a null terminated string.

 

avr-libc has very useful functions to concatenate strings (instead of sending a value string, say "123", you might prefer sending something like "v=123", concateating "v=" and "123" strings....

 

BTW, let us go back to PC  : which compiler/toolchain do you use; avr-libc is meant for avr-gcc (comes with Atmel Studio and Arduino )

 

Edited horrors removed...

Last Edited: Wed. Oct 18, 2017 - 11:55 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

First of all i want to thank you all for your replies.

dbrion0606: i've already achieved communication with my pc by sending a string from atmega8515 and read it on my terminal.I'm using ATMEL STUDIO 7 and my terminal is the HyperSerialPort.

clawson: i want the output data be separated with comma, and then i will make the graph on some other program . i would be really thankful if someone of you could show me a filter code..

Kartman: i will take a look on avr-gcc stdio. and about 'the number of samples per second that i would like to output', i don't know, just as many samples as i need to show up the notch in 50Hz.

Last Edited: Wed. Oct 18, 2017 - 12:23 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

you should send as fast as possible (depends on your Xal), giving some time for filter computation (on timer interrupts?).

Kartman and me linked to avr-libc (Kartman was explicit, my links were implicit)

 

If you are under GNU linux, https://balau82.wordpress.com/20...

give a fancy solution (python's matplotlib can be used to store drawings into a file, ready to publish; python can compute a fft -need numpy IIRC-, a log -> one can display spectrum....) with less than 40 lines (and he does not convert into ASCII, making things 2-4 times faster, but very hard to debug-) It is easy to read and adapt IMO . This solution can handle up to 10 000 samples per second (Nyquist gives 100 sps for 50 hz...)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

dbrion0606, thank you for your advices, but i have a question that may seem easy for you. You told me, "Best solution is to convert your values (they are integers) into null terminated string  numbers, and then, to send them on the serial line."

My filter function gives me many filtered data and then when i call this function into main must send all of them to my terminal screen, but how?i mean could you show me a code example?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Read up on printf(). This function can convert numeric values to strings and send it out the serial port.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

i'm trying to do that using itoa().As my filter function is an int..Is it wrong?

Sorry for my stupid question,one more time.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I suppose that, at a given time, you have

elapsed milliseconds eMs

raw value rawV

filtered falue filteredV

each and every of them bieing integers

 

Luxury solution (is 8515 big enough?)

char string2Send[20];
sprintf(string2Send,"%d,%d,%d\n", eMs, rawV, filteredV);  // decimal
// or
sprintf(string2Send,"%x,%x,%x\n",eMs, rawV, filteredV);  // hexa, according to Kartman recommandation : shorter time to transmit

I bet you can send "string2Send", as you wrote you know how to send a string

 

Smaller solution

 

#ifdef KARTMAN
#define RADIX 16
#else
#define RADIX 10
#endif
itoa(eMs,string2Send,RADIX );
// send string2Send
// send a comma
// same thing with other values

 

For a very fast solution (warrants fixed time transmission : see balau's blog (but binary transmitting is hard to debug and not reliable)

 

BTW : these solution are faster whan numbers are small : your filter cannot work in the same thread, and you  should put the filtering part in a high priority thread (timer interrupts). 

Did you already simulate a filter on a PC? whith which software? Did you try to make it simpler (using 8 -16 bits arithmetic)?

AS PC are more comfortable than avrs when debugging, of course you should answer "yes".

 

Are you a student or a hobbyist? or ? (hobbyists are more isolated, have more free time but no teachers to help them....)

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am a student.No i didn't simulate a filter on my PC and i know very little things about programming but thanks to your help i hope to learn things and implement the filter.

I will try to implement the parts of code that you send to me.Thanks for your time!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The title of the thread is,

Display filtered data

And, in the opening post,

gtzgr wrote:
I would like to know, how to display all the filtered data  on my terminal screen.

It seems that question has now been answered?

 

We now seem to be onto a different question; viz, "How to implement a digital filter" - which is entirely unrelated to the title & OP.

 

To learn how to do digital filters, you should certainly start on a PC - that would be a far more convenient & appropriate environment.

 

Here is a free, downloadable book:

The Scientist and Engineer's Guide to Digital Signal Processing
Steven W. Smith, Ph.D.

 http://www.dspguide.com/

 

Once you understand the principles of doing digital filters, you could consider whether an AVR is actually an appropriate target for your requirement.

 

If it is, then - and only then - you can start worrying about the specific details of how to get a digital filter on a small, resource-constrained microcontroller ...

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

gtzgr wrote:
I am a student

What subject(s) are you studying?

 

Presumably, you have some recommended reading for this topic ... ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

gtzgr wrote:
 my terminal is the HyperSerialPort.

I hadn't heard of that before.

 

Is this it: http://download.cnet.com/windows/hyper-serial-port/3260-20_4-10308953-1.html ?

 

The http://www.hyperserialport.com/ mentioned there just goes to a GoDaddy holding page.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It's the first link.I will study this book thanks a lot.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Is digital filtering part of what your are taught (then a book is redundent) ?

Does your school have computer with some simulation programs installed (I do not claim to be an expert in that domain, but Matlab/Octave are very popular; R should be but is not; python might be implemented;  maybe there are hundreds I do not know; Fortran or C are ... more complicated,

advantages of C is that, once you have written your filter and tested it (with ideal settings; with arithmetic limitations  one can manage that avr limitations are reproduced by C http://pubs.opengroup.org/online... ) , porting to avr-gcc  should somewhat easy (Oh I forgot to ask were you taught C.... schools assignements can be very weird, according to Murphys) ?

?

Why did you/your school choose the 8515 -is rather old, has limited RAM/flesh-?

 

What did you already implement (if one tries to explain something you already did, one loses time writing ... and you loose time reading!)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

These are very good questions.

 

See also #13.

 

EDIT

 

the link should be: http://pubs.opengroup.org/onlinepubs/009695399/basedefs/stdint.h.html

 

EDIT 2

 

And, for the data types available in AVR-GCC, see: https://gcc.gnu.org/wiki/avr-gcc#Type_Layout

 

and: http://www.nongnu.org/avr-libc/user-manual/group__avr__stdint.html

Last Edited: Thu. Oct 19, 2017 - 11:48 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In  wikipedia, they somtimes make an effort to have things easy to read -and recursive filters could /can have trouble with numbers representation) : https://en.wikipedia.org/wiki/C_data_types#inttypes.h

 

[political nonsense removed - next time you will be banned for a week]

Last Edited: Fri. Oct 20, 2017 - 09:41 AM