I wanna start a project to monitor my cpu ram usage. But can't seems to figure out how to make it work.
I have:
-Arduino UNO
-Oil pressure gauge for cars
-a step up transformer
Thing is,I know that the gauge requires 12V to work so I've used a transformer to get 12v from the 5v arduino board. And I'm stuck. As for the software,I manage to find one but doesn't seems to work too.
Thing is,I know that the gauge requires 12V to work so I've used a transformer to get 12v from the 5v arduino board
A transformer is an AC device - you need a step-up (aka boost) converter.
As for the software,I manage to find one but doesn't seems to work too.
So, you're telling us that some code we can't see is doing something that you don't want it to, but you don't want to show us the code or tell us what it is doing?
To get the RAM usage you have to know the address of the top of the heap and bottom of the stack.
The top of heap can be found by malloc()ing a single byte and recording the address returned. If you are not malloc()ing in the program then this only needs to be done once.
The bottom of the stack is pointed to by the SP register, I'm pretty sure you can read that using assembly (it's been many years since I have done this), but another way is to get the address of a local variable in a function. For example
long readSP () {
byte x;
return (long)&x; // not exactly the SP but close enough, probably 2 bytes off
}
Once you have those numbers you can derive the free/used RAM and use that number to control a PWM pin to move the gauge needle.
Graynomad:
To get the RAM usage you have to know the address of the top of the heap and bottom of the stack.
The top of heap can be found by malloc()ing a single byte and recording the address returned. If you are not malloc()ing in the program then this only needs to be done once.
The bottom of the stack is pointed to by the SP register, I'm pretty sure you can read that using assembly (it's been many years since I have done this), but another way is to get the address of a local variable in a function. For example
long readSP () {
byte x;
return (long)&x; // not exactly the SP but close enough, probably 2 bytes off
}
Once you have those numbers you can derive the free/used RAM and use that number to control a PWM pin to move the gauge needle.
psikyo:
I wanna start a project to monitor my cpu ram usage.
Which CPU? The one on your Arduino or the PC on your desktop?
Thing is,I know that the gauge requires 12V to work...
If it is old analog automotive gauge then I doubt it. Those things are typically a bimetallic strip. The warmer the strip gets the farther to the right the needle moves. If that's how it works than total energy is what is important.
The one on my pc. I wanna read the ram of my pc desktop.
So if you open the Windows Task Manager and click the Performance tab (Win 7 for example) you get a sliding chart that shows Physical Memory Usage History and also a number with I guess "at the moment" Physical Memory, you want to show that number as a 0-100 dial gauge movement?
I don't know what it takes to get that number to pop out on the serial port for an Arduino to do something with it.
[quote author=Coding Badly link=msg=2982360 date=1477940529]
You are the only one on this thread who has mentioned "unused RAM". I suggest you find out what @psikyo actually wants.
[/quote]RAM usage in a multi-tasking system is very different from RAM usage on a small microcontroller. This shift stated in reply #13 and confirmed in #14 throws a very new light on the thread. The remaining Arduino aspect is the control of the gauge, the PC part deserves further clarification.