How to make visible light sensor module - led

How to make visible light sensor module from existing LDR module (I have one of it). Both of it have same circuit but different sensors. So,I would like to buy phototransistor separately as LDR is slow to respond to 5mm while LED which flickers at >56000 baud rate.
Circuit Diagram
Can I replace sensor in circuit diagram with TEPT5600 phototransistor official page.

Yes, you can replace the LDR sensor with a phototransistor like TEPT5600/TEPT4400 which works at ~20ns(which is suitable for >9600 BR). The Collector needs to go to pin 2 (+) and the Emitter to pin 1 (-).

Related

Embedded system: How to identify required tasks/threads?

I'm studying embedded programming, so I'm new in this field.
Can someone explain how to identify tasks/threads from given system description. Also, how can I estimate timing constraints, execution times... I'm really stuck.
Here is system description I'm working on:
Implement a 2 degree of freedom servo motor system. A two-axis joystick is used for controlling servo motors. Additionally, enable recording and reproducing the user path of the joystick, so that identical movement could be replicated multiple times. It is necessary to support the recording of 3 motion profiles with a length of at least 5 minutes. The profile needs to be recorded to a non-volatile memory, and the recording/playback control via the joystick button. Provide appropriate signalling for the current selected profile and operating mode (recording / playback) using one LED for each profile. In the RT-Thread system realize the necessary drivers on the Raspberry Pi Pico platform as support for the devices used and the application itself that implements the described system with clear separated threads for each of the observed functionalities.
It is tempting to partition functionally, but in practice you should partition based on deadlines, determinism and update rates. For simple systems, that may turn out to be the same as a functional partitioning. The part:
clear separated threads for each of the observed functionalities
May lead you to an inappropriate partitioning. However that may be the partitioning your tutor expects even if it is sub-optimal.
There is probably no single solution, but obvious candidates for tasks are:
Joystick reader,
Servo controller,
Recorder,
Replayer.
Now considering these candidates, it can be seen that the joystick control and replay control are mutually exclusive, and also that replay itself is selected through the joystick button. Therefore it makes sense to make that a single task. Not least because the replayer will communicate with the servo controller in the same way as the joystick. So you might have:
Joystick reader / replayer,
Servo controller,
Recorder.
The recorder is necessarily a separate thread because access to NV memory may be slower and non-deterministic. You would need to feed time and x/y position data in a message queue of sufficient length to ensure the recording does not affect the timing motion control.
It is not clear what king of servo you are using or if your application is responsible for the PID motion control or simply sends a position signal to a servo controller. If the latter, there may be no reason to separate teh servo control from the reader/replayer. In which case you would have:
Joystick reader / replayer / Servo controller,
Recorder.
Other solutions are possible. For example the recorder might record the servo position over time rather the joystick position, and have the servo controller handle replay.
Joystick reader,
Servo controller / replayer,
Recorder.
That makes sense if the Joystick polling and Servo update rates differ, because you'd what to replay what the servo did, not what the joystick did.

Would my design of this adressable rgb led work?

im fairly new to this thing and my grammar isnt good,but here we go.
Im planning to light up a clear casted figurine for my school project by using addressable rgb sk6812,its 2020 in size and pretty convenient for my figure since its fairly small (15cm) and kinda cramped. Im trying to light it up with some effect like a burst going on,please see my tinkercad pic,sorry its the easiest method i can do for now attached design
As you can see i try to spread the whole led in every limb,the no 1 (first to get the data in) led are placed on the chest and im thinking if i can just spread the data out line from led no 1 to the next led around it and so on would make a ripple/burst like effect,also sorry for the cramped cable since my sk6812 only had 4 pin instead of bigger old 6 neopixel on tinkercad so im making it as close as possible with my situation,will it work without any future problem? the thing gonna be on for 3 days straight,also the attiny is just an example,i'll use a 5-12v powered led strip controller for the real deal like this one BTF SP105E Bluetooth Controller that probably already have everything in check for powering the led (its phone controlled too!).
Do i need bypass capacitor for each of led? or any extra resistor? my friend said the controller are packed with so many pattern and could be so fast that he afraid the led lifespan would shortened,but since both of us are kinda new i would like to hear for some experienced people here.
Here's my tinkercad sketch link
Any help would be great! Thnak you.
Looks good!
You are supposed to have a capacitor at each LED to help smooth out voltage when it is turning on and off rapidly, but you might be able to get away with not using them if you have thick, short wires and/or you do not turn the LEDs on too brightly.
Also, the LED boards you show in the picture already have capacitors on them. If you are not using these boards, it is pretty easy to solder a capacitor directly onto each LED.
You do not need any resistors.

How to generate/handle listeners on Trinket?

Is there any way to implement a listener? On a PC machine it's easy to do - forking the process and using a global variable can tell you if your listener found something, but I don't know if this is possible to do on a trinket, or maybe there's some kind of option to handle this?
Basically, I just want to do some stuff when some pin is low (for example, joining two pins by a switch, then when switch is pulled do something).
Thank you a lot!
You can either use interrupts or pin polling, i.e. if you connect the switch to a pin that is linked to an external interrupt (see the datasheet of the MCU for this), this interrupt will be triggered when the state on the pin changes i.e. from high to low. The interrupt will be handled in an Interrupt Service Routine (ISR) then. This is similar to a listener.
Alternatively you can poll the state of the pin in specific periods. Polling means checking if state is high or low i.e. each 50 ms (possibly triggered by a timer). This is not the best solution.
http://avrlogic.blogspot.de/2014/11/polling.html
http://avrlogic.blogspot.de/2014/11/switch-interfacing.html

Charging Indicator for Battery (Battery Monitor)

We see in all today electronic devices like mobile a Visual battery charging indicator,that a graphical Container composed of bars that increases one by one when the battery is charged for long, and decreases one by one when the mobile is used for long time.
I see the same thing laptop in every GUI operating system like windows and Linux.
I am not sure whether i am posting in the right place, because this requires a System Programmer and Electrical Engineer.
A Visual view of my Question is here:
http://gickr.com/results4/anim_eaccb534-1b58-ec74-697d-cd082c367a25.gif
I am thinking from long long ago , under what logic this works?
How the Program is managed to Monitor the battery.
I made a simple logic based on Amps-hour, that how much time the bar should increase when the battery is in charging mode.??? But that does not work perfectly for me.
Also i read a battery indicator Android application source code of my fried, but the function he used were System Calls based on Andriod Kernel (Linux Kernel).
I need the thing from the scratch....
I need this logic to know............. Because i am working on an Operating system kernel project, which later on will need battery charging monitor.
But the thing i will implement right now is to show just percentage on the Console Screen.
Please give me an idea how i can do it.... Thanks in Advance
Integrating amps over time is not a reliable way to code a battery meter. Use voltage instead.
Refer to the battery's datasheet for a graph of (approximate) voltage vs. charge level.
Obtain an analog input to your CPU. If it's a microcontroller with a built-in ADC, then hopefully that's sufficient.
Plug a reference voltage (e.g. a zener diode) into the analog input. As the power supply voltage decreases, the reference will appear to increase because the ADC only measures voltage proportionally. The CPU may include a built-in reference voltage generator that you can mux to the ADC, or the ADC might always measure relative to a fixed reference instead of rail-to-rail. Consult the ADC manual (or ADC section of micro controller manual) for details.
Ensure that the ADC provides sufficient accuracy.
Sample the battery level and run a simple low-pass filter to eliminate noise, like displayed_level = (displayed_level * 0.95) + (measured_level * 0.05). Run that through an approximate function mapping the apparent reference voltage to the charge level.
Display the charge level.

Send game controller message to a race game use Xinput

I have a steering wheel game controller.Now I am trying to write a driver for playing a race game such as NFS-17.I knew the game is using Xinput.I will write the driver in C.
My questions:
1) How to send message to the game when I turned the steering wheel.
2) Is it using SendMessage().
3) If use SendMessage(), how to get the game window's handle and which wParam and lParam should I send.
XInput is for xbox360 controllers. For the steering wheel X axis you can use the two Triggers of the gamepad. XInput is a getter/setter nothing more :P It gets you the state of the connected controller and reports if there is something connected or not at your request only, it doesn't monitor or save anything anywhere nor does it send messages to apps that have input focus. Sending messages is your job with an app that you could build.
Now, down to what you actually need. You could write a simple C++ app that would scan the state of the controller, but wait...you don't have a xbox360 controller :P So first test how your app would respond to your steering wheel with its oem driver. If you can't read it as connected on any usb port (check on MSDN the GetInputState()) then try using a windows generic driver (let it install whatever suits it, it might even perceive your steering wheel as a xbox360 they are very similar to a point, difference being the number of axis and buttons with more expensive wheels).
Then when you achieved actually reading the state of your controller (steering wheel), use GetHDC( windowhandle), where windowhandle is retrieved via (I don't remember for sure)FindWindow(name/title of the window). Use alt-tab to check with mouseover whatever title is used for the game's window.
When you are in possession of the window handle and the device context you can send messages to its call back WndProc function corespondent via the window handle and even display texts/draw images/shapes via the device context. The messages should be the according virtualkey codes (VK_UP for UP arrow for instance...look it up) that would be pushed on the keyboard if there wasn't a wheel available. The trick is to simulate a PWM for every degree of the wheel rotation. Just send a high frequency messages of alternating push/release of the VK_LEFT key code for a high degree of wheel turn to the left and for steering lock just send one KEY_DOWN message until the steering lock is removed and then a KEY_UP message followed by the corresponding frequency of alternations again. For low degrees of wheel make larger pauses between the key press/release messages.
A bonus of making a driver is that you can adjust the sensitivity, button correlations, dead zones for your own liking.
On the other hand there are simulators like this already and then again you could build your own steering wheel with 6+1 transmision using just a usb comunication API(read/write data from/to USB port, nothing fancy :) ) from windows, a microcontroller (PIC,atmega, nxp, etc whatever cheaper and with hardware USB at the ready or plus a usb controller), variable resistors for the X,Y, etc axis and some parts for the driving system. Good luck and post on youtube :P!
P.S. Hell it is way too late now, but hey...I felt I needed to write some mambo-jambo I have never done, but which would work... if I wasn't that lazy. :)
Update: xInput may work if compatible (probably high end wheels and joys), but directx knows of steering wheels too, all of them. For me it was the only solution. Microsoft says both XInput and directX should be used as XINput offers audio and more stuff for compatible products.
The algorythm is sound, though open to many implementations. I implemented it successfully for GTA SA, since dedicated tools didn't support my version. Now I have Acc and Brake from the pedals, finally:) I used a timer to achieve a certain frequency (of own choice, empiric stuff), and modulated the pulse width from near 0s to full period (light touch of the pedal and continuously applied pedal to the metal). On every pulse I sent two messages: W/S keys down at the start of the pulse and W/S keys up when the calculated pulse width has reached its end value. The formula for Pulse Width is percentage of total width, the same percentage or modified by a sensitivity setting for instance the pedal had traveled from its max travel distance (DirectInput reports a integer number in[-1000,1000] I think. [-fullbrake,fullacceleration]).

Resources