Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I am doing this project:
I have 4 inputs. These are push buttons, connected to a microcontroller.
Each time a push button is pressed, say for example pushbutton_1 is pressed, the press of a switch button should be recognised as a HIGH.
In its normal unpressed state it should be recognised as a LOW.
Then using serial communication i should transfer it to a computer.
Along with this, i need to implement a count for each button.
Each time a push button is pressed, the count that is assigned to that push button, should increment by 1.
The data arriving through serial communication should be transferred to an excel sheet/database.
The excel sheet/database should display a count for each pushbutton.
I have 4 important question areas:
Which microcontroller should i use? (I have experience with arduino development platform)
How do i implement the transfer of data from microcontroller to computer via serial communication?
Afterwards, how do i transfer the arriving data to MS excel/database?
How do i run implement the system in realtime?
Please suggest me the best possible way to implement this system.
To solve this using an MPU like an RPi via the Internet, its pretty trivial. To do this:
Wire your switches to the GPIO inputs on the Pi. This is a trivial example: http://razzpisampler.oreilly.com/ch07.html
When the state changes, send a message via a realtime service such as PubNub (free for student and other uses: http://www.pubnub.com/free-evangelism-program/)
On a remote "server-side", take the data received via the subscriber logic write to a CSV.
If you followed these directions, you would use the PubNub python client to publish the data from the Pi: https://github.com/pubnub/python/tree/master/python#publish
and then you would use python (PubNub supports over 70 languages, so you could use python or the language of your choice) to subscribe to the pushbutton data channel(s)
https://github.com/pubnub/python/tree/master/python#subscribe
You could even make a cool realtime updating web page in HTML/JS using the PubNub JS client
Source: https://github.com/pubnub/javascript/tree/master/web
Docs: http://www.pubnub.com/docs/javascript/api/reference.html#subscribe
to dynamically update a dashboard, with no file writing needed.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
Improve this question
I am making an application using Node.js and Express. I am able to save files to the server using multer, however while sending responses I have two options,
Send the URI of the image in JSON, and let the front-end call this to display the image.
Send the image data using some form of encoding like Base64 as part of JSON.
Since I am new to web development, I am confused as to which option to use. Some people have said that the first option requires two API calls, so can be slow. While I have also heard that the second option will take up more memory resources.
What other things should I consider while choosing, and is there any other way of sending images to the client side?
Option 1
Is less complex since no conversion is needed. These 2 API calls won't slow you down. The image size is way more important!!.. The file can be stored/accessed directly on filesystem and served from there. Also a filedownload is implemented in a short period of time. Also the base64 encoding makes the file roughly ~33% (!!) bigger what has a huge impact on large files regarding performance.
Option 2
Base 64 is more secure as nobody can link to your website as described here .
You only need to use base64 for security reasons OR if you have to transfer the image data as string if you cannot transfer it as binary.
Use Case
If this is your private non-productive project just try out both and use the one you like. In the end you are learning something.. It's only important to stay consistent !
If one option fits better to you, just implement it the way you like. You can always refactor a given part of the application later when you may have more experience or when the core parts of your application are finished. Sometimes, after working a while with one of the techniques it gets more clear which approach to use.
For learning it's sometimes better to go ahead, and implement something what works
and start to refactor as problems occur. Rather than overengineering small
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
Say I have a program that does the following:
wait for key press
Once key pressed, do complex query (takes 10 seconds) and print the result
repeat
Now if I my key presses are 10 seconds apart, this would not be a problem. How do I handle key presses really close together. Even worse, keys pressed at the exact same time.
Is this information bound to be lost?
I know threading might be an option but what is general way of doing this?
Is it possible to just store every key pressed even though other code is running and be able to tend to it later?
Interrupts. Universally, computers provide a mechanism for peripherals to request the attention of a CPU by asserting an Interrupt Request Signal. The CPU, when it is ready to accept interrupts, responds by saving minimal state somewhere, then executing code which can query the peripheral, possibly accepting data (keypress) from it.
If you are using an OS this is all hidden by the kernel, which typically exposes some mechanisms for you to choose how you want to deal with it:
Queue up the keypresses and process them later. Thus if I want to have query 1,3,5 in that order, I can press those keys in succession and go for a smoke while your long processing occurs.
Discard the lookahead keypresses; thus demand the user interact with a lousy UI. Search for "homer simpson work from home" to see how to work around this.
If you are using an OS, you might need to look up various ioctl's to enable this behaviour, use a UI packages similar to curses, or other.
If you aren't using an OS, your job is both tougher and easier: you have to write the code to talk to the keyboard, but implementing the policy is 1/10 th work of figuring out some baroque UI library.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 11 months ago.
Improve this question
I´ve a question according sensor programming. I´m searching a sensor that tells me, for example, if a glass of water is more than half full. I´ve already googled that, but I can´t find anything.
So my questions are:
Where can I buy such a sensor?
What programming language do I need to control such a sensor?
Thanks for answers..
Update from comments below one of the answers
What I really need it for is a big container, in which is some corn. I
want to use the sensor to tell me, just as the corn is under a defined
point of the container. So that I can calculate, at which time I have
to refill the container.
Your sensor could be a level sensor. There are several principles on which level sensors work (see here). Some of them will work with granular solid material. (For example, an ultrasonic range sensor could shoot a pulse at the surface of corn mass, detect the reflection, measure round trip time of flight.)
... or it could be a proximity sensor, as somebody had suggested above.
... or it could be a weight sensor. Here's an application note on weighing vessels.
If you google "level sensor for grains", you may find something useful.
What language to use would depend on what you will connect connect the sensor to. If it will be connected to a microcontroller, the language would be C. If it will be connected to a PC, then it would depend a lot on the particular model of the sensor.
By the way, here's a web group dedicated to sensors.
I would imagine you could use a similar mechanism to a car's fuel tank. Have a mechanism that stays afloat in the container with an attached arm and a magnet on it, then using a Hall sensor you can observe the change in hall reading as the floating part rises or falls within the container.
"What I really need it for is a big container, in which is some corn."
Perhaps one of those sensors that are used to ensure garage entry ways are clear before an automatic garage door is allowed to close. It uses an optical beam of light.
Do you know the size of the glass in question? You could just get a scale and work out how heavy the glass would be when it is half full of water. My guess is that you could probably find a sensor that could do this and it would most likely need to be written in C.
This guy seems to be having the same problems:
http://forums.makezine.com/comments.php?DiscussionID=6052
Good luck.
Also check out Arduino for micro controller electronics.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
The goal
I would love to have a multi user system (based on linux) using only one X11 session with multiple screens and pairs of mouse and keyboard. So two (or more) people can work with the same computer sharing not only the same hardware but also the same "screen" (which would be split into two physical screens of course, but you could move a window to your partner for example...). Sharing the windows should not only make it more convenient to "show" your partner what you have done - if user A started to work on something using a complex application (assert that it wouldn't be convenient to save the files and open them in the other session) moving the window of the application to user B should be as simple as moving a window within your own screen. That's why I call it a "seamless" multi user session.
Possible solutions
I read about X11 "multi seat" in this article which doesn't have the features that I want. It uses a session for each user rather than one single session.
I found XI2 aka Xinput2 which provides a multi-pointer support. This allows having two separate mouse pointers controlled by two mice. I read that you can assign two keyboards to the two mice providing independant focus and text input. But I wonder if the clipboards (both "real" and "middle mouse button" clipboards) are treated separately too... I found only few information on XI2 multi pointer feature but no "field report".
Another, completely different idea would be having two separate X11 sessions on the computer but share the windows using X11-forward between the two sessions. BUT: As far as I know, you can not share a X11-forwarded window so that user A runs an application and while it runs, send the window to user B. As I know, only user B can run an application on the hardware of user A and display the window on it's own X11 session. That's again not what I want... Or am I wrong and it is possible to forward a window via X11-forwarding AFTER the application has been started?
edit: I just found XPRA which is similar to X11 forwarding but allows detaching and attaching a running application from / to an X11 session. I give it a try now.
Any other ideas to get this done?
I think I found a solution:
Win Switch (uses Xpra, licenced under GPL3)
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
We need to capture live video and display easily on Linux. We need a cheap card or USB device with a simple API. Anyone want to share some experience?
Use the video4linux library. I've used it with a c++ program and was able to capture webcam frames within about an hour. (Very easy to use and setup)
If you need to program, you're best off using GStreamer, a multimedia framework under Linux.
Cheese, mentioned by jackbravo, is based on GStreamer, as is Flumotion, a streaming server I work on.
As mentioned, Use dvgrab to capture from a Firewire interface from the camera, then use tools such as ffmpeg (command line) or kino (simple gui video editor) to process the video as needed. PCI based Firewire cards are relatively inexpensive and easy to find.
Here are some examples:
continuous capture from firewire, autosplit every couple of minutes
dvgrab --size 500 --autosplit <filename>
watch the camera live
dvgrab - | mplayer -
Be aware that some recent distros (e.g. Fedora8) are using new but half-baked firewire drivers. However, Ubuntu works great.
There are "sealed" camera solutions out there with mini-webservers and an ethernet port on the back. Just plug it in to the network, set its IP, and open up a browser... in linux or wherever
If you want to capture in linux, I once had a cheap webcam capturing single frames in a perl script, which could have been modified for real time - though that was about 10 years ago. Anyway, its possible :-/
There's the cheese gnome application. Really simple to use. Not too much features, just video capture.
openCV will allow you to capture individual frames from a camera and save to disk. If you need to then manipulate these to create a video, I would suggest netpbm, a pretty powerful set of command line tools you can use with some shell scripting to make a video or do whatever it is you need.
Another option is to use Firewire (IEEE1394) cameras, such as most common DV camcorders. They tend to work really well and give a lot better video than cheap web cams, and there is a plethora of tools in Linux for working with dv video, such as dvgrab.
If you use java, v4l4j makes it very simple to capture frames from any V4L device. It also allows you to control the device from java. I used it with a PTZ webcam (logitech quickam orbit), and I could control usual thigs like brightness, saturation and auto-white balance, but also the tilt and pan of the camera. Very handy !