Science topic
Microcontroller Programming - Science topic
Explore the latest questions and answers in Microcontroller Programming, and find Microcontroller Programming experts.
Questions related to Microcontroller Programming
I have a doubt regarding wavelet transform.
If we have power constraints while making an algorithm , is it advisable to go with time domain features, or frequency domain features.
Will Wavelet based feature extraction and processing consume more power when incorporated in a Micro Controller Unit?
Or does it depend on the type of wavelet used?
Thank You and Regards
Can anyone provide me with an Arduino code to read the Razor IMU which is connected with Mega 2560?
How to reboot/reset ESP32 without pressing the reboot button on the board. I'm using platformio VScode IDE. Is there a way I can do that using the IDE without touching the board?

I have had great success with Tasmota firmware on a dozen Sonoff basic devices and a couple of TH16s.
I'm looking to go deeper and if possible create code for a chlorine level capacitive level detector.
Using a concept I have used in the past, with a 32 bit 8 core microcontroller, of applying a voltage momentarily to a capacitor to an output Pin, while simultaneously starting a counter, switching that pin from output to input, then when the voltage on that same pin falls to 1/2 VCC the counter stops and that count value is compared. The 1/2 VCC threshold was simply when the state of the now input pin transitioned from on to off.
I'd like to do a similar thing using the ESP 8266 with a couple of large plates on the outside of a plastic chlorine tank and determine the approximate level based on how long it takes to charge this crude capacitor which should vary via tank level.
I'm not looking for super high accuracy like +/- .1" but something +/- .5" would be sufficient.
While I am quite adept at programming in Assembly, my C skills are standard & basic in python.
I'd like to make this part of my Node Red Home Automation system running on a Raspberry Pi so as to monitor the tank's chlorine level via my cell phone.
Anyone use the ESP8266 for this or similar purpose? Ideally I'd like to use a Sonoff Basic as it has the power supply and is self contained. I'd obviously have to add some external leads to the tank's capacitor plates.

Well there are different boards around.
1st. I see CH340 USB chipset on these photos. (Can’t find the source) but I read that this one are fakes/not official and have different layout like mention before. There are some with a CP210X around, as well, but mostly with same size, layout and pinout (Can’t prove if I’m right/wrong).
2nd. If you want to buy the ESP32, inside of the official Datasheet there are already 6 different boards mentioned. Some with single core instead of dual core. However, they are even with 34 to 40 pinout if you buy something like Node MCU, Wroom, ect.
3rd. Almost every company/producer do updates on they boards. (Especially boards for Arduino). Sometimes they write “Rev. X” or similar.
As you can see, there are many kinds of layout around which can do the same things but with one or two different. Most of the user here won’t even notice this until they need something which isn’t available.



I need my ESP8266 to be an access point and command multiplexer to more devices. I need at 5 to 7 devices - 4 to 6 slaves and one master that sends them commands by TCP/IP and receives responses. I can't broadcast UDP, and commands must be sent to all nodes in less than 250ms.
The issue is that by default ESP8266 doesn't allow more than 4 connections. There are a compile-time variable max_connections set to 4. Some say that this limit can be set to 8, but ESP8266 won't support more sockets than 5. I'm here to ask: is there any way to surpass that limit? I have three possibilities on how to do that:
- Somehow configure ESP8266 that it can support more connections - perhaps it's just a question of reserved resources? Maybe somewhere in the firmware, there is another limit that can be changed? Disconnect one socket and connect another device in its place - will this be reliable?
- Use something else - but what? I need something small and fairly cheap. Other platforms I considered:
- Arduino YUN - too big and quite expensive, unsure about the limit of clients
- CC3000 - doesn't support AP mode
- Onion Omega - unavailable and unsure about the limit of clients
- Raspberry PI 3 - too expensive and too big
- Raspberry PI Zero + WiFi dongle - PI Zero is unavailable below 10x it's official price
- Intel Edison - verified it works, but is very expensive
- Sparkfun Particle P0/P1 - not sure if AP mode is controllable and what is the limit of clients
I could do with a very small embedded router and an ESP8266 to control it - but can't find any such part either.
3. There is also one solution that I really don't want to do, but have considered it - stacking ESP's - I can do that, but this will be a very big hack and will make large problems with connecting devices to this monstrosity - must make more than one wifi network, will have to keep track how many devices are connected to each network etc.
Could you please tell me if #1 is possible? If not, any recommendations on #2?

Hello Every one,
I am trying to communicate my PSOC microcontroller chip 5LP (LP035) with Raspberry Pi. I have written Pi program in C and java(in order to check the speed of communication between two languages)
PSOC(microcontroller) is acting as slave and Pi is a Master.
Between the communication I set up a mask that is responsible for giving back the required channel value to the master (Pi).
My code was working properly but now it start behaving different (I have not change any thing!) .
Firstly, It only works correct when master send a mask value either 1 or 3.
Secondly: If my program is working (communicating) properly with Pi (java programed) and if I run the same program with Pi (C programmed) and vise versa. I start getting garbage values and sometimes correct value along with garbage value.
I dont understand where the problem is laying.
I will be very thankful to you If any body can help me in it!
Looking forward to hearing from you!
Regards
Working via Matlab and Arduino with using the serial port from arduino to Host computer ?
Wearable devices typically need a compact operating system to fit into low-power microcontrollers.
I have a question regarding Pentium 68000/2732/6821 based micro-controller design,
What would be the input and output (I/O) and memory map of the bottom of the schematic shown?
Here would be the schematic for the example, could anyone give me advice to understand how the schematic works?
Any help or comments would be appreciated.

With older data sheets of microcontrollers were having such fabrication information. From last some years it is not seen. From designing & interfacing prospective we are following old standard pull-ups / pull-downs. Does with technologies there are changes? For example, for I2C interfacing 10K pull-up are standard values. For low power & reduced MCU voltages & open drain cases it is observed that even 47K pull-up also works well. Can we use 1M registers as pull-up & in open drain cases?
i am working on dv-hop localization algorithm. i have implemented the protocol in ns2 but when m running its tcl script, it shows error if any one have error free dv-hop tcl script then please give it. it will be great help for my research or else if any one can solve this error i will be thankful, error is: (num_nodes is set 9 (_o15 cmd line 1) invoked from within "_o15 cmd addr" invoked from within "catch "$self cmd $args" ret" invoked from within "if [catch "$self cmd $args" ret] { set cls [$self info class] global errorInfo set savedInfo $errorInfo error "error when calling class $cls: $args" $..." (procedure "_o15" line 2) (SplitObject unknown line 2) invoked from within "_o15 addr" ("eval" body line 1) invoked from within "eval $node addr $args" ("default" arm line 2) invoked from within "switch -exact $routingAgent_ { DSDV { set ragent [$self create-dsdv-agent $node] } DSR { $self at 0.0 "$node start-dsr" } AODV { set ragent [$self cre..." (procedure "_o3" line 14) (Simulator create-wireless-node line 14) invoked from within "_o3 create-wireless-node" ("eval" body line 1) invoked from within "eval $self create-wireless-node $args" (procedure "_o3" line 23) (Simulator node line 23) invoked from within "$ns node" ("for" body line 2) invoked from within "for {set i 0} {$i < $val(nn) } { incr i } { set mnode_($i) [$ns node] $mnode_($i) random-motion 0 } " (file "/home/mahnoor/Downloads/dvhop2d/dvhop_802_11.tcl" line 47)
i have attached the code. Please reply soon.
Thanks
What is the maximal sample rate for mpu6050? 1KHZ or?
For a research I need to use 3 Proximity sensors at the tool tip of 3DoF RRR robot arm, aligned to (X3,Y3,Z3) frame. How to convert these sensor readings w.r.t base frame coordinates (X,Y,Z)? What about Eular angles method?
I have LCD (from top way display model LM6059BCW) and i want to use it with microcontroller PIC16F877a. How can I redefined on MicroC software library?
Best Trainer for PIC18F series.
I want to use CSNE151 current sensor in my control loop. Output of this device goes to the microprocessor then i have to decrease this output to 3 volt. i can't find suitable circuit model to apply it. In addition i want to know how can i adjust output of current sensor in my desired level?
Hi,
I just want to broadcast a message to a number of nodes, using Contiki socket.
Of course, there is CORDIC for sin() and cos(), and one could also use precomputed lookup tables for single variable functions like exp() and log(). However, common bivariate functions as pow(a,b) and atan2(a,b) seems to be a little trickier to implement.
I'm considering a simple RISC-like microcontroller such as the AVR. It can perform fast adds and shitfs and loads but it has no built-in multiplier hardware.
I just figured out to transfer data in my project is using synchronous communication. But, i need to change data to frame. FYI my project is to transfer image from OV7670 (camera module) to PC using RS-232. Thank's :)
a snap dragon arm 7 micro controller clocked at 1Ghz has better performance then that of a mediatek arm 7 micro controller clocked at 1Ghz,what is the cause of performance difference??? is it something in the fabrication process,doping,or any other reason,please provide your valuable information .................
I've put the LCD initialization code in CodeVision in different parts of the initialization segment of the program and it only works in certain places , one of which is where the Wizard uses as default.
Is there any explanation why such sequence occurs, or how to put the initializer code for any part in the right place without checking the Wizard?
I am looking for ideas concerning a microcontroller mini project that must include analog inputs. I would prefer a not-so-basic project if possible. Any help is much appreciated.
Hi all,
I want to know exactly what happens in the hardware when HLT command (Halt) is executed in a micro-processor or micro-controller. I have read that it functions in power-saving mode. Could any please help me explaining the exact working of HLT command and the hardware functioning on execution of this.
Regards,
Raghu
OFDM stands for Orthogonal Frequency Division Multiplexing. Seeking to know if it is possible to implement it in microcontroller and how?
I want to control the speed of DC motor via PID by using a microcontroller or a DSP
what's the best PID equation to perform such job?
I want to use an arduino uno +ethernet shield to monitor a surveillance camera in a remote location, create a database for the camera and light an LED at the CO (central office) to indicate fault, when factors to be monitored like power, voltage, operating temperature exceed the database created.
I was thinking about a low-cost gamma spectroscopy system which will be using a CsI(Tl) coupled to a photodiode as a detector and an arduino microcontroller instead of a MCA for the signal processing.
In your opinion, is it possible to emerge a decent spectrum out of the noise with this system?
Thank you in advance for your answers!
I am trying to implement LEDs dimming using the GPRS shield V2.0 and arduino uno when i am outside of Bluetooth range, by sending commands via text/sms with each text setting the bulb to the appropriate brightness level. I am really stuck here and need some help on how i can do this and build a working circuit that dims LEDs using sms commands via the GPRS shield. Any help would greatly be appreciated!!
I am doing an MPPT algorithm. I face the problem of analog input in my dsPIC30F4011 microcontroller.program is run sucessfully in softwariy (mikroC PRO) but hardwarely output are not come,
Programming for to read analog input LED Blinking in port E AND F ---->
unsigned int temp_res;
void main(){
TRISE = 0x0000; //Port E is output (for ADC results)
TRISF =0x0000;
ADCHS = 0x0002; //Connect RB10 on AN10 as CH0 input
ADCSSL = 0; //No scan
ADPCFG = 0xFFFB; //RB2 ANALOG INPUT
ADCON1 = 0x0000;
ADCON2 = 0x0000; //Sample time ends with timer 3 clock
ADCON3 = 0x0002; //TAD = internalTCY
ADCON1bits.ADON = 1; //ADC on
while(1)
{
ADCON1bits.SAMP = 1; //ASAM=1, start sampling after conversion ends
Delay_ms(100);
ADCON1bits.SAMP = 0;
while(!ADCON1bits.DONE);
temp_res = ADCBUF0;
ADCON1bits.DONE =0;
TRISE = temp_res ; //Output result on port E
TRISF =(temp_res>>8); //Port F is output (for ADC results)
}
}
I want to develop a microcontroller based system which can communicate with PC/Laptop through USB port. (As simple as possible eg. toggle leds connected to any port of microcontroller when any key is pressed from keyboard).
I worked on atmel's 8051 and atmega microcontrollers. So these families will be preferable to me.
I'm interested in creating my own WirelessHART communication network using blank RF MCUs as the Gateway and the Field Devices as part of my research. I am not an advanced programmer, but I have a general idea - done up to 2nd year BSc level as part of my BEng. So I can't program my own stack from scratch without significant work.
The stack for WirelessHART is available open-source from Nivis (http://www.nivis.com/open_source/) but I'm not sure about how to use Freescale BeeKit (as it briefly mentions) to implement the stack.
I want to burn a hex file of programs written in MATLAB in microcontroller chip but I can't open the hex file.
The attachment below are the errors that are shown when I run the simulation. Can anyone highlight to me what I've done wrong? Thanks in advance.
This my program:
#pragma config OSC = IRCIO67
#pragma config WDT = OFF
#pragma config LVP = OFF
#pragma config PBADEN = OFF
#define SW0 PORTAbits.RA0
#define SW1 PORTAbits.RA1
#define SW2 PORTAbits.RA2
#define SW3 PORTAbits.RA3
#define LOW PORTCbits.RC0
#define MEDIUM PORTCbits.RC1
#define HIGH PORTCbits.RC2
void main()
{
TRISA = 1;
PORTA = 0;
TRISC = 0;
PORTC = 0;
while (1)
{
if(SW0 == 1)
{
LOW = 0;
MEDIUM = 0;
HIGH = 0;
}
if ((SW0 == 0)&&(SW1 == 1)&&(SW2 == 0)&&(SW3 == 0))
{
LOW = 1;
MEDIUM = 0;
HIGH = 0;
}
if ((SW0 == 0)&&(SW1 == 0)&&(SW2 == 1)&&(SW3 == 0))
{
LOW = 0;
MEDIUM = 1;
HIGH = 0;
}
if ((SW0 == 0)&&(SW1 == 0)&&(SW2 == 0)&&(SW3 == 1))
{
LOW = 0;
MEDIUM = 0;
HIGH = 1;
}
}
}
Below are the errors that are shown when I run the simulation.

I started my program by writing subprograms as functions in VHDL. Then I have tested them separately, and all of those subprograms worked fine. Fortunately, when I combined them and started my primality testing, I found that my program was performing well, but for certain number, the program began to output all the results as composite. I was just wondering what problems might cause this bug. By the way, my program was designed to be 32-bit primality testing. However, the program work fine until I test the numbers above 46399. Then all prime and composite numbers outputted the same result as "composite". This really confused me. Please, need your help.
What is the difference between CCS and IAR and which one is better to use? Can anyone help me how to design FIR or IIR filter using MSP430?
In rural areas of India due to over flow of water tanks, a huge amount of water and electric energy is being wasted every day which led to affect our environment. For this we are trying to design a very cheap ultrasonic sensor based water level measuring device through which we can save huge amounts of water as well as electricity. But the problem is that to measure the water level we have to put the sensor in the tank. Condensation of water may happen at the surface of sensor which generates sound waves.
Is condensation of water on the surface of sensor hamper the sensing ability of sensor?
If so, is there any preferred solution to the problem?
I designed a system that has an 8bit PIC microcontroller with a built-in 12b ADC. I know that, by 256x over-sampling, you can increase this ADC resolution to 16bits. This is done by Sigma-Delta modulation. There are wonderful articles on TI, Microchip, ADI's websites describing Sigma-Delta modulation. . My favorite is the one from ADI (Analog Devices): http://www.analog.com/static/imported-files/tutorials/MT-022.pdf
also MT-023 ... Although the description of the theory is absolutely wonderful, I could not find a single article on Microchip's website (or, any other company's) that explains how I can do this in SOFTWARE.
By using my 8bit PIC uC-based system (specifically, PIC16F1783, but, it doesn't matter which PIC), I am perfectly fine with losing my sampling speed. 75 KSPS is what this uC supports at 12bits. 256x oversampling will drop me down to 300 SPS to increase the bit depth from 12b to 16b. I am perfectly fine with that. My specific questions are:
*** Do I need additional hardware to do this ?
*** If not, does anyone have C code to achieve this ? from PURE SOFTWARE ?
*** Assembly code is totally fine too ...
Currently I am working on Pipe inspection robot.
This robot will move into pipe and inspect any damage into pipe or not ?
At the moment I am totally dependent on PID Algorithm to stabilize my Quadrotor. It seems slow to react and to solve errors. If I increase the P co-efficient of PID it becomes highly unstable. I am using Arduino MEGA as my main controller to look after the Controlling Algorithm. Can anyone suggest a more effective control system which can run on my ATMEGA 2560?
I want to plot a nyquist plot for a filter constructed using op-amp. Suppose, if I do not know the transfer function of the filter or its order.
1. Draw the bode plot of the filter which includes Magnitude and Phase responses for 0<w<inf.
2. From the magnitude and phase values, find the complex value for each frequency.
3. Plot Re vs Im.
Is this a correct method?
I would like to find a way to set the time the LED stays on and also set the time the LED stays off in real time. (So I am avoiding the use of the "Delay" function in favor of millis.) But I just can't wrap my head around how to set these two variables seperately without using "Delay."
I am thinking about writing a simple lab practicum for students of informatics (computer programming course) for assembly programming language.
The problem I am having is to identify the best architecture, mainly due to the large number of different instruction sets, address handling, program flow etc.
I have identified three possible solutions and I would like to read about other people’s experiences in this matter.
* The first solution would be to use simpler microcontrollers as the platform because of their simple architecture and reduced instruction set. Also, because it is simple to make them interact with surrounding peripheral devices attached. I believe that this freedom of playing with real physical devices would be interesting and motivating to students. On the other hand, I am afraid that this approach would teach them that computers are programmed to make other devices move around, switch on-off, communicate simple commands etc. whilst on the other hand, sometimes, programming is all about manipulating data, taking inputs and creating outputs, and most of the time, doing it all in memory (compression algorithms, encryption, decryption etc.).
* The second solution would be to go straight to real PC architectures, but not to AMD Phenom or Intel i7 processor instruction set assembler languages, but instead to older Intel chips from the 80x series. This way they could learn the real way x86 architecture works and how it had evolved into what it is now. For this solution, I am afraid that it might teach them outdated ways of coding, stack handling and that it would not give them an opportunity to learn about parallelism, optimizing code for piping etc.
* The third solution would be to design new computer architecture. Of course, to create an emulator that would execute programs written using a whole new instruction set, designed solely for that new computer architecture. This architecture would have a RISC instruction set CPU, a simple limited memory, interrupts, virtual hard drives and other types of permanent memory, input and output devices (all simulated by means of interfacing with physical peripherals of the host machine) etc. By designing a new architecture, I could combine bits from microcontrollers, such as the possibility to directly control virtual devices (step motors, lights and other devices) connected to different kinds or general input output ports, UART etc. while I could also keep all the good things of PC architectures, such as more complex memory handling, parallelism. I could introduce virtualization, etc. The reason I am unsure is because this looks like a very big project and am unsure if it would be an overkill to do something like this, although it is not too complicated, it would only take up too much time.
So there were my three ideas for solving the dilemma (`trilemma`) regarding the question on choosing the best architecture to begin teaching beginner students in programming assembly by preparing a course practicum.
I would like to hear ideas of others and would be grateful for any suggestion from those with experience in this or similar topics.
In a single ATMEGA16 microcontroller we have 4 ports and each port consists of 8 pins. The total number of pins that can be used for accessing each port is 32. But in my hardware implementation I need to give signals to 60 pins. So, can someone explain how to synchronize two microcontrollers?