tag:blogger.com,1999:blog-88605395138844568352024-03-12T16:33:21.325-07:00CHIP PIKO EULearn Arduino, AVR, and STM32, Sensors with free schematics and code.Fizhttp://www.blogger.com/profile/13243157048776399794noreply@blogger.comBlogger8125tag:blogger.com,1999:blog-8860539513884456835.post-13435215966260385412020-10-12T19:33:00.001-07:002020-10-12T20:28:16.231-07:00Different between fuse and circuit breaker with symbols<h1 style="text-align: center;">Different Between Fuse and Circuit Breaker</h1><p style="text-align: justify;"><b>What is the difference between a fuse and a circuit breaker?</b> In electrical circuits, we identify two types of circuit safety, namely Fuse and Circuit Breaker.</p><p style="text-align: justify;">These two components are designed as highly current sensitive devices and are placed in the current path.</p><div class="separator" style="clear: both; text-align: center;"><a href="https://www.chippiko.eu.org/2020/10/different-fuse-circuitbreaker.html" style="margin-left: 1em; margin-right: 1em;"><img alt="Symbol fuse polyfuse circuit breaker" border="0" data-original-height="298" data-original-width="410" src="https://1.bp.blogspot.com/-gCBAjk7PQIc/X4UdPszlkHI/AAAAAAAAC5k/8UV5AludJCopD2vEsG-SS_kLm6hTtvKvQCLcBGAsYHQ/s16000/symbol_of_fuse_and_circuit_breaker.png" title="Different between fuse and circuit breaker with symbols" /></a></div><p style="text-align: justify;">If the current through this component is below the maximum current limit of this component, then this component functions as a closed switch that can deliver current.</p><p style="text-align: justify;">When the current exceeds the maximum limit of the fuse and circuit breaker, both of them will function as open switches, so that the current does not flow into the circuit.</p><p style="text-align: justify;">There are three basic differences between Fuse and Circuit Breaker:</p><p style="text-align: justify;"></p><ol><li>Fuse if the current through it equals or exceeds the maximum current of fuse, then the fuse will break and must be replaced.<br /><br />While the circuit breaker if the current through it is the same or exceeds the maximum current from the circuit breaker, the circuit breaker contacts will open so that it is like an open switch position.<br /><br />However, circuit breakers can be manually reset to change positions such as closed switches or can be used repeatedly without having to be replaced.</li><li>Fuse is generally used for small currents, while circuit breakers are used for high currents.</li><li>Most of the physical size of the Fuse is smaller than the Circuit Breaker.</li></ol><p></p><p style="text-align: justify;">Examples of using Fuse are in audio systems such as amplifiers both on active speakers to car amplifiers, voltage stabilizers, car electrical systems, television, radio and many more.</p><p style="text-align: justify;">However, as technology advances, now Fuse has a feature that can disconnect and connect the circuit automatically, known as the PolyFuse fuse.</p><p style="text-align: justify;"><br /></p><h2 style="text-align: justify;">PolyFuse</h2><p style="text-align: justify;">PolyFuse is a type of fuse used in electronic circuits that can break off and reconnect the current automatically.</p><p style="text-align: justify;">Apart from Polyfuse, the names that are often used are polymeric PTC (positive temperature coefficient), multiFuse, or polySwitch.</p><p style="text-align: justify;">The way polyfuse works is if the polyfuse have a maximum current limit of 2A, and the current through it is equal to 2A or more, then the fuse is automatically cut off. And when the current from 2A decreases, then PolyFuse will automatically reconnect.</p><p style="text-align: justify;">With this advantage, polyFuse has been widely used in electronic to automotive devices as a very important component for circuit security.</p><p style="text-align: justify;">Good use with low to high currents to prevent overcurrent. An example of the most common use of polyFuse is on the Arduino board.</p><p style="text-align: justify;">What is Arduino? You can read the explanation in the article "What is Arduino".</p><p style="text-align: justify;">If you are someone who likes Arduino or is working on a project with it, when you connect or accidentally connect Power VCC to GND, the Arduino board will turn off automatically and when the connection is disconnected, Arduino will be active again.</p><p style="text-align: justify;">If this polyfuse is not used, then when you connect the VCC and GND, the microcontroller and other components may be damaged and burnt.</p><p style="text-align: justify;">Thus a brief explanation of Fuse and Circuit Breaker, hopefully the article "Difference between Fuse and Circuit Breaker" can add to your insight in the field of electronics and electricity.</p><p style="text-align: justify;">Thank you for visiting the Chip Piko Eu website and hope it is useful.</p>Fizhttp://www.blogger.com/profile/13243157048776399794noreply@blogger.com0tag:blogger.com,1999:blog-8860539513884456835.post-21093478006227211402020-10-12T18:39:00.005-07:002020-10-12T18:42:52.025-07:003 Ways To Reset Arduino With Schematic And Program Code<h1 style="text-align: center;">3 Ways to Arduino Reset</h1>
<p style="text-align: justify;">
<b>3 ways to reset Arduino with schematic and program code</b> - In some cases
arduino project, we will need arduino restart or a reset mode of
microcontroller to position the program at 0x00000000, which will impact the
reading of the program from the beginning.
</p>
<p style="text-align: justify;">
There are 3 methods to reset the Arduino and this can also be applied to other
AVR variant microcontrollers (reset arduino uno, reset arduino nano and
other), "Hard Reset ","Soft Reset", and "Combination"
</p>
<p style="text-align: justify;">
Hard Reset means that Arduino will reset when a trigger button is pressed,
like we press the reset button microcontroller directly on the physical
microcontroller (hardware).
</p>
<p style="text-align: justify;">
Soft Reset means resetting the microcontroller via Program Codes (arduino
reset command)
</p>
<p style="text-align: justify;">
Combination means We will use the program code to trigger the reset pin so
that arduino will read the program from the beginning.
</p>
<p style="text-align: justify;"><br /></p>
<h2 style="text-align: justify;">A. Arduino Hard Reset</h2>
<p style="text-align: justify;">
In the Arduino hardware reset method, we will need a button that is directly
connected to the default arduino reset button pin.
</p>
<p style="text-align: justify;">
<b>Attention!</b> in this hard reset method we don't say arduino boards
like arduino uno, nano, micro and so on but we say atmega328, raight?.
</p>
<p style="text-align: justify;">
In addition to the hard reset method, we give an example using the Arduino
board.
</p>
<p style="text-align: justify;">
For example ATmega328. The reset pin is on the PC6 pin. This microcontroller
will reset if pin PC6 is in the LOW position.
</p>
<p style="text-align: justify;">
So, if the reset button is pressed, PC6 will be connected to ground and a
reset will occur.
</p>
<p style="text-align: justify;">
To keep PC6 going HIGH as long as the button is not pressed, we need to use a
Pull-up resistor to hang up at the HIGH voltage.
</p>
<p style="text-align: justify;">
Common values of resistor pull-up is 10K. for the schematic you can see in the
following image.
</p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><img alt="atmega328 reset button schematic" border="0" data-original-height="330" data-original-width="471" src="https://1.bp.blogspot.com/-cU2AWawgYsc/X4UF8k1byII/AAAAAAAAC5Y/YS9YYhnoby0uL0uYk34nG-J2Kj6JfNW_QCLcBGAsYHQ/s16000/RESET_ATMEGA328.png" style="margin-left: auto; margin-right: auto;" title="3 ways to reset Arduino with schematic and program code" /></td></tr><tr><td class="tr-caption" style="text-align: center;">Arduino Reset Button</td></tr></tbody></table><p style="text-align: justify;"><br /></p><h2 style="text-align: justify;">B. Arduino Software Reset</h2>
<p style="text-align: justify;">
In the second program this is a simpler way to reset your Arduino. we using
resetFunc to declare reset to address 0.
</p>
<p style="text-align: justify;">This method does not need a schematic.</p>
<p style="text-align: justify;">
For program code arduino software reset, please upload the following arduino
reset code program to your Arduino, then open Serial Monitor.
</p>
<!--HTML generated using hilite.me--><div style="background: rgb(255, 255, 255); border-width: .1em .1em .1em .1em; border: 0.1em solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="color: #00aaaa;">void</span> (* resetFunc) (<span style="color: #00aaaa;">void</span>) = <span style="color: #009999;">0</span>;
<span style="color: #00aaaa;">void</span> <span style="color: #00aa00;">setup</span>() {
Serial.begin(<span style="color: #009999;">9600</span>);
Serial.println(<span style="color: #aa5500;">"Reset Succes"</span>);
delay(<span style="color: #009999;">5000</span>);
}
<span style="color: #00aaaa;">void</span> <span style="color: #00aa00;">loop</span>() {
Serial.println(<span style="color: #aa5500;">"Go to Reset!"</span>);
<span style="color: #0000aa;">for</span> (<span style="color: #00aaaa;">int</span> cnt = <span style="color: #009999;">0</span>; cnt < <span style="color: #009999;">20</span>; cnt++) {
Serial.print(<span style="color: #aa5500;">"."</span>);
delay(<span style="color: #009999;">50</span>);
}
Serial.println(<span style="color: #aa5500;">""</span>);
delay(<span style="color: #009999;">3000</span>);
resetFunc();
Serial.println(<span style="color: #aa5500;">"Reset Failed"</span>);
}
</pre></div>
<p style="text-align: justify;"><br /></p>
<h2 style="text-align: left;">
C. Arduino Auto Reset (Combination of Software and Hardware)
</h2>
<p style="text-align: justify;">
This method combine hardware and software. Pin reset arduino will
triggered by other digital pin.
</p>
<p style="text-align: justify;">
Let's say we using pin digital pin 2 in this tutorial. you can use other
digital pins, according to your needs. Look at this image.</p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><img alt="arduino reset software" border="0" data-original-height="618" data-original-width="773" height="320" src="https://1.bp.blogspot.com/-2lRjZA7VD9E/X4UE5belwpI/AAAAAAAAC5M/TLoI6UrYfEkdv621pmTxhKeTP4XP1Y9OwCLcBGAsYHQ/w400-h320/arduino%2Breset%2Bsoftware.png" style="margin-left: auto; margin-right: auto;" title="3 ways to reset Arduino with schematic and program code" width="400" /></td></tr><tr><td class="tr-caption" style="text-align: center;">Arduino Reset Software<br /></td></tr></tbody></table>
<p style="text-align: justify;">
connect digital pin 2 to the reset pin. Upload the following program to your
Arduino board, then click Serial Monitor. You can see whether your Arduino
board has successfully reset or not.
</p>
<!--HTML generated using hilite.me--><div style="background: rgb(255, 255, 255); border-width: .1em .1em .1em .1em; border: 0.1em solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><span style="color: #4c8317;">#define pinReset 2</span>
<span style="color: #00aaaa;">void</span> <span style="color: #00aa00;">setup</span>() {
digitalWrite(pinReset, HIGH);
Serial.begin(<span style="color: #009999;">9600</span>);
Serial.println(<span style="color: #aa5500;">"Reset Succes"</span>);
pinMode(pinReset, OUTPUT);
delay(<span style="color: #009999;">3000</span>);
}
<span style="color: #00aaaa;">void</span> <span style="color: #00aa00;">loop</span>() {
Serial.println(<span style="color: #aa5500;">"Go to Reset!"</span>);
<span style="color: #0000aa;">for</span> (<span style="color: #00aaaa;">int</span> cnt = <span style="color: #009999;">0</span>; cnt < <span style="color: #009999;">20</span>; cnt++) {
Serial.print(<span style="color: #aa5500;">"."</span>);
delay(<span style="color: #009999;">50</span>);
}
Serial.println(<span style="color: #aa5500;">""</span>);
delay(<span style="color: #009999;">3000</span>);
digitalWrite(pinReset, LOW);
Serial.println(<span style="color: #aa5500;">"Reset Failed"</span>);
}
</pre></div>
<br />
<h3 style="text-align: justify;">How this method work?</h3>
<p style="text-align: justify;">
We first define the reset pin used, which is digital pin 2. Then for the setup
() function, at the beginning of the program we immediately apply digital pin
2 to output High logic (1).
</p>
<p style="text-align: justify;">
This results in the microcontroller never being "reset", because the
microcontroller will reset when given Low (0) logic.
</p>
<p style="text-align: justify;">
We initialize serial to be able to display data to Serial Monito with the
command Serial.begin (9600).
</p>
<p style="text-align: justify;">
Then in this part of the setup () function we give the command to the Serial
Monitor that the Reset was successful. Why? Because when the reset occurs, it
will definitely read the setup () function first and will tell us via the
serial monitor that the microcontroller has been reset.
</p>
<p style="text-align: justify;">
In the loop () function, the main command that does the reset is digitalWrite
(pinReset, LOW);
</p>
<p style="text-align: justify;">
When the reset pin receives logic Low (0) from digital pin 2, the
microcontroller will reset quickly, and will read back the setup program ()
then loop ();
</p>
<p style="text-align: justify;">
However, when the reset does not occur, the serial monitor will provide
information. Reset failed, because we have made the command Serial.println
("Reset Failed");
</p>
<p style="text-align: justify;">
<i>#tags: reset pin arduino, arduino nano reset pin, reset arduino code,
software reset arduino, reset button in arduino</i>
</p>
Fizhttp://www.blogger.com/profile/13243157048776399794noreply@blogger.com1tag:blogger.com,1999:blog-8860539513884456835.post-82491401904729106252020-06-29T21:00:00.010-07:002020-10-12T19:05:00.692-07:00STM32 Tutorial - STM32 EEPROM Emulation Arduino<div>
<h1 style="text-align: center;">STM32 EEPROM Blue Pill</h1><div style="text-align: justify;"><div style="text-align: justify;"><div><div><b><i><a href="https://www.chippiko.eu.org/2020/06/stm32-eeprom-arduino.html">STM32 EEPROM Emulation</a></i></b> - EEPROM is an extension of Electrically Erasable Programmable Read-Only Memory, a memory chip that can store data even if power or resources are disconnected.</div><div><br /></div></div></div>
<div style="text-align: justify;">
Generally every microcontroller already has an Internal EEPROM, this makes
the circuit simpler without having to add an external chip.
</div>
<div style="text-align: justify;"><br /></div>
<div style="text-align: justify;">
Unlike Arduino which has an internal non-volatile storage chip, some Blue
Pill devices do not have it. For this reason, if we want to save data to
Blue Pill, we need a method that can allocate program flash memory as
EEPROM.
</div>
<div style="text-align: justify;"><br /></div>
<div style="text-align: justify;">
In the official language of the ST datasheet, this memory allocation is
called <b><i>STM32 EEPROM Emulation</i></b>. I have never used this on Arduino, so from that I shared a little
program in this Article.
</div>
<div style="text-align: justify;"><br /></div>
<h2>A. STM32 EEPROM Emulation</h2>
<div style="text-align: justify;">
This emulation is done by considering the limitation of Flash memory and
some requirements. This approach requires at least two pages of flash
memory of the same size allocated for non-volatile data. For a more
complete explanation of this <b>EEPROM Emulation</b>, please read the
official ST document.
</div><div style="text-align: justify;"><br /></div><div style="text-align: justify;"><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><img alt="STM32 Tutorial, STM32 EEPROM Emulation Arduino, How to Access Read Write STM32 EEPROM Blue Pill Using Arduino IDE" border="0" data-original-height="408" data-original-width="640" height="408" src="https://1.bp.blogspot.com/-sbQXoLDtQ6E/Xvq3ftl30XI/AAAAAAAAB7A/zlOfaFJ3YlM9HSqRMhp3tX34UQVSiFwEgCK4BGAsYHg/w640-h408/stm32%2Beeprom%2Barduino.png" style="margin-left: auto; margin-right: auto;" title="STM32 Tutorial - STM32 EEPROM Emulation Arduino" width="640" /></td></tr><tr><td class="tr-caption" style="text-align: center;">STM32 EEPROM Arduino<br /></td></tr></tbody></table></div>
<div style="text-align: justify;"><br /></div>
<div style="text-align: justify;">
Officially, to program this chip using software from the ST itself named
STM32CubeIDE. But because I'm not familiar with it, I just use Arduino IDE
because there are already many libraries available.
</div>
<div style="text-align: justify;"><br /></div>
<div style="text-align: justify;">
Well, because the Arduino IDE is basically an IDE for programming AVR,
someone developed a library board for this chip to be used in the Arduino
IDE. This is very useful.
</div>
<div style="text-align: justify;"><br /></div>
<h2>B. Library for STM32 Emulation Arduino</h2>
<div style="text-align: justify;">
The library board to support this chip to be programmed using the Arduino
IDE has several options. However, the library board that I use on this
project is
<a href="https://github.com/stm32duino/Arduino_Core_STM32" rel="nofollow" target="_blank">STM32 Arduino Core</a>.
</div>
<div style="text-align: justify;"><br /></div>
<div style="text-align: justify;">
This Arduino Core STM32 tries to emulate this non-volatile storage access
way as in Arduino. STM32 Arduino Core provides this library which I
managed to try.
</div>
<div style="text-align: justify;"><br /></div>
<div style="text-align: justify;">
If we use arduino, to write data just use "EEPROM.write (address, data)"
and read with "EEPROM.read (address)".
</div>
<div style="text-align: justify;"><br /></div>
<div style="text-align: justify;">
Whereas what I use to write is "EEPROMwrite (address, data)" and reads
with "EEPROMread (address, data_data)".
</div>
<div style="text-align: justify;"><br /></div>
<div style="text-align: justify;">
The STM32 program is to use ST-LINK V2 Clone (China) and for serial
monitor communication I connect FTDI on pins A9 and A10.
</div>
<div style="text-align: justify;"><br /></div>
<div style="text-align: justify;">
Below is the program code that I have tested and succeeded. Please upload
the following
<a href="https://www.chippiko.eu.org/2020/06/stm32-tutorial-stm32-eeprom-emulation.html">STM32 EEPROM</a>
code to your STM32 and open Serial Monitor to see the stored data and the
results of reading the data.
</div>
<div style="text-align: justify;"><br /></div><h2 style="text-align: justify;">C. Schematic For Testing</h2><div>To program this Blue Pill, I use ST Link V2. For serial communication, using FTDI, please follow the following table</div><div><div style="text-align: center;"><br /></div><table border="1" bordercolor="#888" cellspacing="0" style="border-collapse: collapse; border-color: rgb(136, 136, 136); border-width: 1px; text-align: center;"><tbody><tr><td style="min-width: 60px;">STM32</td><td style="min-width: 60px;">FTDI</td></tr><tr><td> A9</td><td>RX</td></tr><tr><td style="min-width: 60px;"> A10</td><td style="min-width: 60px;">TX</td></tr></tbody></table><br /></div>
<h2>D. Progam Code STM32 EEPROM Emulation</h2>
<div style="text-align: justify;">Program:</div>
</div>
<!--HTML generated using hilite.me-->
<div style="background: rgb(248, 248, 248); border: white; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0px;"><span style="color: #bc7a00;">#include <EEPROM.h></span>
<span style="color: green; font-weight: bold;">const</span> <span style="color: #b00040;">int</span> addressEEPROM_min <span style="color: #666666;">=</span> <span style="color: #666666;">0</span>; <span style="color: #408080; font-style: italic;">// Specify the address restrictions you want to use.</span>
<span style="color: green; font-weight: bold;">const</span> <span style="color: #b00040;">int</span> addressEEPROM_max <span style="color: #666666;">=</span> <span style="color: #666666;">4095</span>; <span style="color: #408080; font-style: italic;">// For example, the maximum is 4095, which means we allocate 4KB of memory (4096 bytes) for the Virtual EEPROM.</span>
<span style="color: #b00040;">float</span> latitude <span style="color: #666666;">=</span> <span style="color: #666666;">4.158919</span>; <span style="color: #408080; font-style: italic;">// This is an example of data that you want to save to EEPROM.</span>
<span style="color: #b00040;">float</span> longitude <span style="color: #666666;">=</span> <span style="color: #666666;">96.124843</span>; <span style="color: #408080; font-style: italic;">// Coordinate data consisting of Latitude and Longitude.</span>
<span style="color: #b00040;">int</span> addressLat <span style="color: #666666;">=</span> <span style="color: #666666;">0</span>; <span style="color: #408080; font-style: italic;">// The number of characters in the latitude value is 8, so the address starts from 0 to 8.</span>
<span style="color: #b00040;">int</span> addressLon <span style="color: #666666;">=</span> <span style="color: #666666;">9</span>; <span style="color: #408080; font-style: italic;">// The number of characters in the longitude value is 9, so the address starts from 9 to 17.</span>
<span style="color: #b00040;">void</span> <span style="color: blue;">setup</span>()
{
Serial.begin(<span style="color: #666666;">9600</span>);
delay(<span style="color: #666666;">100</span>);
String lat <span style="color: #666666;">=</span> String (latitude, <span style="color: #666666;">6</span>); <span style="color: #408080; font-style: italic;">// Data to be saved to EEPROM is a String. This line is used for the conversion of float to String.</span>
String lon <span style="color: #666666;">=</span> String (longitude, <span style="color: #666666;">6</span>); <span style="color: #408080; font-style: italic;">// Value 6 shows how many digits behind the comma will be converted.</span>
<span style="color: #408080; font-style: italic;">// ------------------- Write Data Commands -------------------</span>
Serial.println(<span style="color: #ba2121;">" -----------------------------------------"</span>);
Serial.println(<span style="color: #ba2121;">"| Writing Latitude to EEPROM | Saved |"</span>);
EEPROMwrite(addressLat, lat);
Serial.println(<span style="color: #ba2121;">"| Writing Longitude to EEPROM | Saved |"</span>);
EEPROMwrite(addressLon, lon);
Serial.println(<span style="color: #ba2121;">" -----------------------------------------"</span>);
Serial.println(<span style="color: #ba2121;">"</span><span style="color: #bb6622; font-weight: bold;">\n</span><span style="color: #ba2121;">"</span>);
delay(<span style="color: #666666;">1000</span>);
<span style="color: #408080; font-style: italic;">//----------------------------------------------------------</span>
<span style="color: #408080; font-style: italic;">// ------------------- Read Data Commands -------------------</span>
Serial.println(<span style="color: #ba2121;">"Baca data dari EEPROM....."</span>);
Serial.print(<span style="color: #ba2121;">"Latitude : "</span>);
Serial.println(EEPROMread(addressLat, <span style="color: #666666;">8</span>)); <span style="color: #408080; font-style: italic;">// Get data from address 0 with 8 characters.</span>
Serial.print(<span style="color: #ba2121;">"Longitude : "</span>);
Serial.println(EEPROMread(addressLon, <span style="color: #666666;">9</span>)); <span style="color: #408080; font-style: italic;">// Get data from address 9 with a total of 9 characters.</span>
Serial.println(<span style="color: #ba2121;">"</span><span style="color: #bb6622; font-weight: bold;">\n</span><span style="color: #ba2121;">"</span>);
delay(<span style="color: #666666;">1000</span>);
<span style="color: #408080; font-style: italic;">//----------------------------------------------------------</span>
Serial.println(<span style="color: #ba2121;">"Now, please COMMENT *Write Data Commands* to deactivate data write commands to EEPROM."</span>);
delay(<span style="color: #666666;">5000</span>);
Serial.println(<span style="color: #ba2121;">"Then, please press the reset button or remove STM32 from the computer to see whether the data from the EEPROM is still stored or not."</span>);
}
<span style="color: #b00040;">void</span> <span style="color: blue;">loop</span>()
{
}
String <span style="color: blue;">EEPROMread</span>(<span style="color: #b00040;">int</span> StartAddr, <span style="color: #b00040;">int</span> StringLength)
{
<span style="color: #b00040;">char</span> buf[StringLength <span style="color: #666666;">+</span> <span style="color: #666666;">1</span>];
eeprom_read_string(StartAddr, buf, StringLength <span style="color: #666666;">+</span> <span style="color: #666666;">1</span>);
String dataStr <span style="color: #666666;">=</span> buf;
<span style="color: green; font-weight: bold;">return</span> dataStr;
}
<span style="color: #b00040;">void</span> <span style="color: blue;">EEPROMwrite</span>(<span style="color: #b00040;">int</span> StartAddr, String DataString)
{
<span style="color: #b00040;">int</span> val <span style="color: #666666;">=</span> DataString.length() <span style="color: #666666;">+</span> <span style="color: #666666;">1</span>;
<span style="color: #b00040;">char</span> StringChar[val];
<span style="color: #b00040;">char</span> buff[val];
DataString.toCharArray(StringChar, val);
strcpy(buff, StringChar);
eeprom_write_string(StartAddr, buff);
}
boolean <span style="color: blue;">eeprom_is_addr_ok</span>(<span style="color: #b00040;">int</span> addr)
{
<span style="color: green; font-weight: bold;">return</span> ((addr <span style="color: #666666;">>=</span> addressEEPROM_min) <span style="color: #666666;">&&</span> (addr <span style="color: #666666;"><=</span> addressEEPROM_max));
}
boolean <span style="color: blue;">eeprom_write_bytes</span>(<span style="color: #b00040;">int</span> startAddr, <span style="color: green; font-weight: bold;">const</span> byte<span style="color: #666666;">*</span> array, <span style="color: #b00040;">int</span> numBytes)
{
<span style="color: #b00040;">int</span> i;
<span style="color: green; font-weight: bold;">if</span> (<span style="color: #666666;">!</span>eeprom_is_addr_ok(startAddr) <span style="color: #666666;">||</span> <span style="color: #666666;">!</span>eeprom_is_addr_ok(startAddr <span style="color: #666666;">+</span> numBytes))
{
<span style="color: green; font-weight: bold;">return</span> <span style="color: green;">false</span>;
}
<span style="color: green; font-weight: bold;">for</span> (i <span style="color: #666666;">=</span> <span style="color: #666666;">0</span>; i <span style="color: #666666;"><</span> numBytes; i<span style="color: #666666;">++</span>)
{
EEPROM.write(startAddr <span style="color: #666666;">+</span> i, array[i]);
}
<span style="color: green; font-weight: bold;">return</span> <span style="color: green;">true</span>;
}
boolean <span style="color: blue;">eeprom_write_string</span>(<span style="color: #b00040;">int</span> addr, <span style="color: green; font-weight: bold;">const</span> <span style="color: #b00040;">char</span><span style="color: #666666;">*</span> string)
{
<span style="color: #b00040;">int</span> numBytes; <span style="color: #408080; font-style: italic;">// number of actual bytes to be written</span>
numBytes <span style="color: #666666;">=</span> strlen(string) <span style="color: #666666;">+</span> <span style="color: #666666;">1</span>; <span style="color: #408080; font-style: italic;">// Write string content plus byte terminator string (0x00)</span>
<span style="color: green; font-weight: bold;">return</span> eeprom_write_bytes(addr, (<span style="color: green; font-weight: bold;">const</span> byte<span style="color: #666666;">*</span>)string, numBytes);
}
boolean <span style="color: blue;">eeprom_read_string</span>(<span style="color: #b00040;">int</span> addr, <span style="color: #b00040;">char</span><span style="color: #666666;">*</span> buffer, <span style="color: #b00040;">int</span> bufSize)
{
byte ch; <span style="color: #408080; font-style: italic;">// read bytes from eeprom</span>
<span style="color: #b00040;">int</span> bytesRead; <span style="color: #408080; font-style: italic;">// number of bytes read so far</span>
<span style="color: green; font-weight: bold;">if</span> (<span style="color: #666666;">!</span>eeprom_is_addr_ok(addr)) <span style="color: #408080; font-style: italic;">// check the starting address</span>
{
<span style="color: green; font-weight: bold;">return</span> <span style="color: green;">false</span>;
}
<span style="color: green; font-weight: bold;">if</span> (bufSize <span style="color: #666666;">==</span> <span style="color: #666666;">0</span>) <span style="color: #408080; font-style: italic;">// how can we store bytes in an empty buffer?</span>
{
<span style="color: green; font-weight: bold;">return</span> <span style="color: green;">false</span>;
}
<span style="color: green; font-weight: bold;">if</span> (bufSize <span style="color: #666666;">==</span> <span style="color: #666666;">1</span>)
{
buffer[<span style="color: #666666;">0</span>] <span style="color: #666666;">=</span> <span style="color: #666666;">0</span>;
<span style="color: green; font-weight: bold;">return</span> <span style="color: green;">true</span>;
}
bytesRead <span style="color: #666666;">=</span> <span style="color: #666666;">0</span>; <span style="color: #408080; font-style: italic;">// initialize a byte counter</span>
ch <span style="color: #666666;">=</span> EEPROM.read(addr <span style="color: #666666;">+</span> bytesRead); <span style="color: #408080; font-style: italic;">// read the next byte from eeprom</span>
buffer[bytesRead] <span style="color: #666666;">=</span> ch; <span style="color: #408080; font-style: italic;">// save it in the user's buffer</span>
bytesRead<span style="color: #666666;">++</span>;
<span style="color: #408080; font-style: italic;">// if no stop conditions are met, read the next byte from the eeprom</span>
<span style="color: green; font-weight: bold;">while</span> ( (ch <span style="color: #666666;">!=</span> <span style="color: #666666;">0x00</span>) <span style="color: #666666;">&&</span> (bytesRead <span style="color: #666666;"><</span> bufSize) <span style="color: #666666;">&&</span> ((addr <span style="color: #666666;">+</span> bytesRead) <span style="color: #666666;"><=</span> addressEEPROM_max) )
{
ch <span style="color: #666666;">=</span> EEPROM.read(addr <span style="color: #666666;">+</span> bytesRead);
buffer[bytesRead] <span style="color: #666666;">=</span> ch; <span style="color: #408080; font-style: italic;">// save it in the user's buffer</span>
bytesRead<span style="color: #666666;">++</span>;
}
<span style="color: green; font-weight: bold;">if</span> ((ch <span style="color: #666666;">!=</span> <span style="color: #666666;">0x00</span>) <span style="color: #666666;">&&</span> (bytesRead <span style="color: #666666;">>=</span> <span style="color: #666666;">1</span>)) <span style="color: #408080; font-style: italic;">// make sure the user buffer has the string terminator, (0x00) as the last byte</span>
{
buffer[bytesRead <span style="color: #666666;">-</span> <span style="color: #666666;">1</span>] <span style="color: #666666;">=</span> <span style="color: #666666;">0</span>;
}
<span style="color: green; font-weight: bold;">return</span> <span style="color: green;">true</span>;
}
</pre>
</div>
</div>
<div><br /></div>
<div>Results:</div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><img alt="STM32 Tutorial, STM32 EEPROM Emulation Arduino" border="0" data-original-height="373" data-original-width="849" src="https://1.bp.blogspot.com/-bfvBCuQePkY/XvqzcKPuTFI/AAAAAAAAB6k/s8dqkMDDg_g4G7mxDMQyGQkA0FBJmhWiwCK4BGAsYHg/d/STM32%2BEEPROM%2BEmulation.PNG" style="margin-left: auto; margin-right: auto;" title="STM32 Tutorial - STM32 EEPROM Emulation Arduino" /></td></tr><tr><td class="tr-caption" style="text-align: center;">Result from STM32 EEPROM<br /></td></tr></tbody></table><div class="separator" style="clear: both; text-align: center;"><br /></div>
<div class="separator" style="clear: both; text-align: center;">
<div style="text-align: justify;">
<br class="Apple-interchange-newline" /><div style="text-align: justify;">May be useful.</div></div>
</div>
Fizhttp://www.blogger.com/profile/13243157048776399794noreply@blogger.com5tag:blogger.com,1999:blog-8860539513884456835.post-42427475512205489892020-06-29T19:04:00.002-07:002020-06-29T19:04:48.040-07:00Download Page <h1 style="clear: both; text-align: center;">
Halaman Download Library, Hardware, Sketsa dan Lainnya</h1>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
Di sini berisi file yang dapat didownload dari projek yang ada di website ini.<br />
<br />
<br />
<h2 style="text-align: center;">
STM32 Arduino</h2><div style="text-align: center;">
<a class="buttonx" href="https://drive.google.com/file/d/1MrLJ9w7DrWHciEva13-qv4B-ZbQH-SUe/view?usp=sharing" target="_blank"> Download File Board STM32 Arduino Core</a></div>
<div style="text-align: center;">
<a class="buttonx" href="https://drive.google.com/file/d/1N6XJxlIct3t_1gSNtCQ43W47xK0VCZP3/view?usp=sharing" target="_blank"> Download File generic_boot20_pc13.bin</a>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-4avPoVBfC9s/Xq-WUs1GpFI/AAAAAAAAAlc/jDMkAWVQ95YcobZlHJLEUO04BfP_QaejQCLcBGAsYHQ/s1600/The-Generic-STM32F103-Pinout-Diagram-1.jpg" style="margin-left: 1em; margin-right: 1em;"><img alt="STM32 Pin Mapping Arduino" border="0" data-original-height="1131" data-original-width="1600" src="https://1.bp.blogspot.com/-4avPoVBfC9s/Xq-WUs1GpFI/AAAAAAAAAlc/jDMkAWVQ95YcobZlHJLEUO04BfP_QaejQCLcBGAsYHQ/d/The-Generic-STM32F103-Pinout-Diagram-1.jpg" title="STM32 Pin Out Image" /></a></div>
<br />
<a class="buttonx" href="https://drive.google.com/file/d/1dx9mhMj58vw4pLMJ2PCkJr52lMeuS9uL/view?usp=sharing" target="_blank"> Download File Gambar Pin Mapping STM32F103 Arduino</a></div><div style="text-align: center;"><a class="buttonx" href="https://drive.google.com/file/d/1RxqrOy9mF1ZqCrc1otp2Gj2kQtEpVlYF/view?usp=sharing" target="_blank">Download Library RTClock STM32</a>
</div>
<div style="text-align: left;">
<br />
<br /></div>
<div style="text-align: left;">
<h2 style="text-align: center;"><br /></h2><h2 style="text-align: center;">
Komponen Fritzing atau Fritzing Part</h2>
</div>
<div style="text-align: left;">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-JgQCye9WxN4/Xq930h5RTMI/AAAAAAAAAk8/b_dAp4PKKVgKmnsuo75S7u5_cIgQHiFtwCLcBGAsYHQ/s1600/BluePill%2BSTM32F103%2BFritzing%2BPart.png" style="margin-left: 1em; margin-right: 1em;"><img alt="Download Part Fritzing STM32 Blue Pill" border="0" data-original-height="255" data-original-width="576" height="176" src="https://1.bp.blogspot.com/-JgQCye9WxN4/Xq930h5RTMI/AAAAAAAAAk8/b_dAp4PKKVgKmnsuo75S7u5_cIgQHiFtwCLcBGAsYHQ/w400-h176/BluePill%2BSTM32F103%2BFritzing%2BPart.png" title="Fritzing STM32 Blue Pill" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a class="buttonx" href="https://drive.google.com/file/d/1uEg2DvMqtyedGo4DuU1hAajqkw3ihkzR/view?usp=sharing" style="text-align: center;" target="_blank">Download File BluePill STM32 Fritzing</a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-5x1jCWqtQ-Q/XtHLR8go2-I/AAAAAAAAAy8/g8sDZjX_reYDtC2558iNqrVBZuPwy5BrACK4BGAsYHg/HC-06%2BFRITZING.png" style="margin-left: 1em; margin-right: 1em;"><img alt="Download Fritzing Part Bluetooth HC 06" border="0" data-original-height="152" data-original-width="335" height="145" src="https://1.bp.blogspot.com/-5x1jCWqtQ-Q/XtHLR8go2-I/AAAAAAAAAy8/g8sDZjX_reYDtC2558iNqrVBZuPwy5BrACK4BGAsYHg/w320-h145/HC-06%2BFRITZING.png" title="Fritzing Bluetooth HC 06" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;"><a href="https://drive.google.com/file/d/1BUAMXhwBBYyyDndRh6DumD9L-1oRP8dE/view?usp=sharing">Download File Bluetooth HC-06 Fritzing</a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div>
<h2 style="clear: both; text-align: center;">
</h2>
<h2 style="clear: both; text-align: center;">
</h2>
<h2 style="clear: both; text-align: center;">
</h2>
<h2 style="clear: both; text-align: center;">
LED MATRIX MAX72xx</h2>
<div class="separator" style="clear: both; text-align: center;">
<a class="buttonx" href="https://drive.google.com/file/d/1albpHooB8L8i1VPmsQwRX_fv7cjT0-Tu/view?usp=sharing" style="text-align: center;" target="_blank">Download Library MD_Parola</a></div>
<div class="separator" style="clear: both; text-align: center;">
<a class="buttonx" href="https://drive.google.com/file/d/1THMyiG_6cJWNbvbiBK_syDUYVeKl9cT_/view?usp=sharing" style="text-align: center;" target="_blank">Download Library MD_MAX72XX</a></div>
</div>
Fizhttp://www.blogger.com/profile/13243157048776399794noreply@blogger.com0tag:blogger.com,1999:blog-8860539513884456835.post-40992781354831499572020-06-27T06:55:00.007-07:002020-12-03T23:28:29.626-08:00How to Save Float To STM32 EEPROM Arduino<h1 style="text-align: center;">Save Float Value To STM32 EEPROM</h1><div style="text-align: justify;">STM32 EEPROM is one of the important things that must be learned. STM32 does not have EEPROM by default, so we can use flash memory for EEPROM allocation. </div><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><img alt="STM32 EEPROM Emulation Arduino Library" border="0" data-original-height="554" data-original-width="857" height="414" src="https://1.bp.blogspot.com/-BNq66m-ww4w/XsqcL1hJRlI/AAAAAAAAAtM/zSHJ6X59e1UXYkyZcQud2lDAcP2pKRZXACK4BGAsYHg/w640-h414/stm32-eeprom-emulation-arduino.png" style="margin-left: auto; margin-right: auto;" title="STM32 EEPROM" width="640" /></td></tr><tr><td class="tr-caption" style="text-align: center;">Save Float to EEPROM STM32</td></tr></tbody></table><h2 style="text-align: center;">
</h2><div style="text-align: justify;">
<div style="text-align: justify;"><br /></div>
<div style="text-align: justify;">This Article has moved <a href="https://www.chippiko.com/2020/12/stm32-eeprom-float.html">here</a>.</div></div><div><div style="text-align: justify;">
</div>
</div>
Fizhttp://www.blogger.com/profile/13243157048776399794noreply@blogger.com2tag:blogger.com,1999:blog-8860539513884456835.post-37210123241269839392020-06-24T05:58:00.003-07:002020-12-03T23:22:51.418-08:00STM32 RTC Internal How to Use It Using Arduino<h2 style="text-align: center;"><div class="separator" style="clear: both; text-align: center;"><img alt="Cara Akses STM32 Blue Pill Internal RTC" border="0" data-original-height="380" data-original-width="640" src="https://1.bp.blogspot.com/-EQGv8DZnDVA/XtouRrquGBI/AAAAAAAAA7w/w8XxoBJADOQVC017MWUgGGhTAxutZESRACK4BGAsYHg/d/STM32%2BBLUE%2BPILL%2BINTERNAL%2BRTC%2BACCESS-min.png" title="STM32 RTC Blue Pill" /></div><div class="separator" style="clear: both; text-align: center;"><br /></div></h2><h1 style="text-align: left;">Blue Pill STM32 RTC, Display to Arduino Serial Monitor</h1><br /><div style="text-align: justify;"> This article has moved <a href="https://www.chippiko.com/2020/12/stm32-rtc-arduino.html">here</a>.</div>
Fizhttp://www.blogger.com/profile/13243157048776399794noreply@blogger.com0tag:blogger.com,1999:blog-8860539513884456835.post-41610270993957792842020-06-22T16:20:00.005-07:002020-06-25T08:13:02.877-07:00libusb couldn't open USB device /dev/bus/usb/001/006: Permission denied.<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;">
<tbody>
<tr>
<td style="text-align: center;">
<a href="https://1.bp.blogspot.com/-n0r7CH3nXto/XtrpX0uATRI/AAAAAAAAA-Y/qb-7SnlkBRktj4mIxJsBJEMVWt2swTlWACK4BGAsYHg/s640/libusb%2Bpermission%2Bdenied%2Barduino%2Blinux-min%2B%25281%2529.png" style="margin-left: auto; margin-right: auto;"><img alt="LibUSB Permission Denied" border="0" data-original-height="452" data-original-width="640" height="452" src="https://1.bp.blogspot.com/-n0r7CH3nXto/XtrpX0uATRI/AAAAAAAAA-Y/qb-7SnlkBRktj4mIxJsBJEMVWt2swTlWACK4BGAsYHg/w640-h452/libusb%2Bpermission%2Bdenied%2Barduino%2Blinux-min%2B%25281%2529.png" title="Linux Permission Denied Arduino" width="640" /></a>
</td>
</tr>
<tr>
<td class="tr-caption" style="text-align: center;">
Image From Pixabay<br />
</td>
</tr>
</tbody>
</table>
<div>
<h2 style="clear: both; text-align: center;"><br /></h2>
<h2 style="clear: both; text-align: center;">
How to Fix Arch Linux Permission Denied Arduino IDE STM32 Microcontroller
</h2>
</div>
<div>
<div class="separator" style="clear: both; text-align: justify;">
This is a problem that I got from my project of programming STM32 using
Arduino IDE on <b>Arch Linux.</b>
</div>
<div class="separator" style="clear: both; text-align: justify;"><br /></div>
<div class="separator" style="clear: both; text-align: justify;">
All the equipment I have installed, starting from the STM32 Core library
board, Libusb library, ST Link, accepts when I check in the terminal using
the "lsusb" command. I am confused as to what causes this.
</div>
</div>
<div class="separator" style="clear: both; text-align: justify;"><br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-EMfVy64Ul2g/Xtor8eEO13I/AAAAAAAAA68/hjWB05PQxQkmEBvfn4CP8fD_Nj1hoHe7wCK4BGAsYHg/s852/libusb%2Bpermission-min.png" style="margin-left: 1em; margin-right: 1em;"><img alt="Linux Permission Denied Arduino" border="0" data-original-height="403" data-original-width="852" src="https://1.bp.blogspot.com/-EMfVy64Ul2g/Xtor8eEO13I/AAAAAAAAA68/hjWB05PQxQkmEBvfn4CP8fD_Nj1hoHe7wCK4BGAsYHg/d/libusb%2Bpermission-min.png" title="Linux Permission Denied Arduino" /></a>
</div>
<div class="separator" style="clear: both; text-align: center;"><br /></div>
<div class="separator" style="clear: both; text-align: center;"><br /></div>
<div class="separator" style="clear: both; text-align: left;">
<div class="separator" style="clear: both; text-align: justify;"><br /></div>
<div class="separator" style="clear: both; text-align: justify;"><br /></div>
<h3 style="clear: both; text-align: justify;">Permission Denied?</h3>
<div class="separator" style="clear: both; text-align: justify;">
I just remembered when using ubuntu. You can read install Arduino Ubuntu
Permission denied on
<a href="https://chippiko.blogspot.com/2020/03/install-arduino-linux-and-atur.html">this page</a>.
</div>
<div class="separator" style="clear: both; text-align: justify;"><br /></div>
<div class="separator" style="clear: both; text-align: justify;">
I tried it on Arch Linux, but there is no dialout in arch linux. Finally I
got it on Arch Linux we used "uucp" and it worked.
</div>
<div class="separator" style="clear: both; text-align: justify;"><br /></div>
</div>
<div class="separator" style="clear: both; text-align: justify;">
<i>libusb couldn't open USB device /dev/bus/usb/001/006: Permission denied.</i>
</div>
<div class="separator" style="clear: both; text-align: justify;">
<i>libusb requires write access to USB device nodes.</i>
</div>
<div class="separator" style="clear: both; text-align: justify;">
<b><br /></b>
</div>
<div class="separator" style="clear: both;">
<h3 style="clear: both; text-align: justify;">
How to fix Permission Denied Arch Linux?
</h3>
<div class="separator" style="clear: both; text-align: justify;">
Are as follows:
</div>
<div class="separator" style="clear: both; text-align: justify;">
There are two steps you must take. Open your <b>Terminal</b>.
</div>
<div class="separator" style="clear: both; text-align: justify;">
<b>1. Modify user accounts.</b>
</div>
<div class="separator" style="clear: both;"><br /></div>
<div class="separator" style="clear: both; text-align: center;">
<i>sudo usermod -a -G uucp <username></i>
</div>
<div class="separator" style="clear: both;"><br /></div>
<div class="separator" style="clear: both; text-align: justify;">
For example your computer username is Asus, then you write:
</div>
<div class="separator" style="clear: both;"><br /></div>
<div class="separator" style="clear: both; text-align: center;">
<i>sudo usermod -a -G uucp asus</i>
</div>
<div class="separator" style="clear: both;"><br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<b>2. Give the port permission to read and write using the terminal with two
commands:</b>
</div>
<div class="separator" style="clear: both;"><br /></div>
<div class="separator" style="clear: both; text-align: center;">
<i>sudo chmod a + rw/dev/bus/usb/..../....</i>
</div>
<div class="separator" style="clear: both;"><br /></div>
<div class="separator" style="clear: both; text-align: justify;">
For example, the detected port name is 001/006, then the command is:<br /><br />
</div>
<div class="separator" style="clear: both; text-align: center;">
<i>sudo chmod a + rw /dev/bus/usb/001/006<br /></i><b><br /></b>
</div>
<div class="separator" style="clear: both; text-align: left;">
<b>3. Done.</b>
</div>
</div>
<div class="separator" style="clear: both; text-align: center;"><br /></div>
Fizhttp://www.blogger.com/profile/13243157048776399794noreply@blogger.com1tag:blogger.com,1999:blog-8860539513884456835.post-16936395480678593092020-06-22T08:26:00.003-07:002020-12-03T23:26:19.520-08:00Serial Monitor Arduino Not Working In Arch Linux<div class="separator" style="clear: both; text-align: center;"><img alt="Linux Serial Monitor Arduino Not Working" border="0" data-original-height="1018" data-original-width="1440" src="https://1.bp.blogspot.com/-7ZLkMrZYqDs/Xtrl9wxihBI/AAAAAAAAA9A/cXN3iC5vkB4qdQRX9Mv3gfr9kN19Gdi-gCK4BGAsYHg/d/Serial%2Bnot%2Bworking%2Barch%2Blinux-min.png" title="Serial Monitor Arduino Not Working" /></div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">This Article has moved <a href="https://www.chippiko.com/2020/12/serial-monitor-not-working-arduino.html">here</a>.</div>
Fizhttp://www.blogger.com/profile/13243157048776399794noreply@blogger.com2