Friday, January 18, 2019

Elektrotehnika i elektronika

http://www.elteh.net/sheme.html

http://www.otpornik.com/projekat/led-osvetljenje-na-230v.html

IZDVAJAMO>

Jednostavni alarm s tiristorom


Shema predstavlja najjednostavniju moguću izvedbu alarma. Kada aktivirate sklopku S2, tiristor Th1 provede i alarm (u ovom slučaju žarulja La1) se upali i ostaje upaljen sve dok se cijeli krug ne resetira djelovanjem na sklopku S1.
Tiristori se znaju sami upaliti kod naglog porasta napona napajanja (uključenja sklopa) pa C1 služi da ublaži taj nagli porast i spriječi lažno uključenje. Ako se to ne događa možete izostaviti C1 iz sheme. Drugi slučaj lažnog uključenja je samoindukcija u kabelima koji vode do Gatea tiristora. To se eliminira ugradnjom kondenzatora C2 koji se isto može izostaviti ako se to ne događa.


***







LED voltmetar za kontrolu 12V akumulatora


Shema prikazuje voltmetar koji je pogodan za kontrolu napona 12V akumulatora prilikom punjenja. Voltmetar pali diode pomoću 4 zener diode kad dosegnu svoj proradni napon, ustvari 1,6V više od nazivnog napona koliko je uglavnom potrebno diodi da provede. Znači ako je napon 13.6V ili više sve ledice svijetle, a ako je manji od 10,6V onda su sve ugašene.

Punjač 12V olovnih akumulatora – 6A


Punjač akumulator puni maksimalnom strujom i počinje je kontinuirano smanjivati kako napon raste otprilike ovim koracima: 13,5V – 4A, 14V – 3A, 14,5V – 2A, 15V – 0A. IC1 i T1 je potrebno montirati na poveći hladnjak jer se dosta grije. Promjenom vrijednosti otpornika R2 regulira se max. napon akumulatora, odnosno struja prorade T1.

LED treptač na 12V


Shema prikazuje jednostavan treptač s LED diodom. Radi na naponu od 12V. Promjenom kondenzatora C1 može se utjecati na učestalost treptanja.

ON - OFF indikator za 230V


Uređaj je namijenjen za indikaciju stanja nekog uređaja ili bolje rečeno sklopke S1. Znači kada je S1 otvorena ili uređaj ugašen upaljena je zelena LED1, a kada je zatvorena ili uređaj radi upaljena je crvena LED2.
Princip rada se temelji na tome da sklopka S1 kada se zatvori, tranzistor T1 dovede u zasićenje i kratko spaja odnosno gasi LED1.
Sklopka S1 mora biti predviđena za napon od 230V i mora podnositi struje trošila kojim upravlja!!



LED dioda na 230V v1


Shema prikazuje jednu od verzija kako LEDicu spojiti na 230V. Umjesto otpornika koji ograničava struju kroz LED koristi se reaktancija kondenzatora. Prednost ove metode je u tome što nema toplinskih gubitaka kao na otporniku. Dioda D1 štiti LED od previsokog napona suprotnog polariteta. Napon kondenzatora treba biti otprilike 2x veći od napona napajanja. Vrijednost kondenzatora se može izračunati prema sljedećoj formuli:
C= I / 6.28 x U x f
C= kapacitet [F]
U= napon [V]
f= frekvencija [Hz]
I= struja kroz LED [A]


Pretvarač 12/230V v4


Shema prikazuje pretvarač 12/245V sa izlaznim naponom kvadratnog oblika. IC 4047 radi kao astabilni multivibrator i njegovi izlazi upravljaju sa dva tranzistora koji napajaju transformator. Frekvencija se može regulirati pomoću potenciometra P1 od 50-400Hz. Tranzistori su predviđeni za snagu transformatora do 60VA.



Oscilator s piezo zvučnikom


Još jedan iz serije jednostavnih oscilatora. Shema je ista kao i kod oscilatora s tranzistorom, samo što je ovdje upotrebljen drugačiji zvučnik. Ustvari korišten je keramički piezo zvučnik. Zbog njegove interne kapacitivnosti ne koristi se dodatni kondenzator. Ostatak sheme je isti, a princip rada temelji se na činjenici da će većina NPN tranzistora zaoscilirati kad se obrnuto polariziraju. Baza se nespaja.


Oscilator s tranzistorom


Još jedna izvedba višenamjenske zujalice. Većina NPN tranzistora će zaoscilirati kad se obrnuto polariziraju. Baza se nespaja. Primjer dan u shemi napaja se s 9V, vuče 4mA struje i oscilira na frekvenciji od 550Hz. Napon napajanja varira u odnosu na tip upotrebljenog tranzistora:
  • 7V za tranzistore male snage (BC109, BC238, 2N2222)
  • 12V za tranzistore srednje snage (BD139)
  • 16V za tranzistor velike snage (BUX22, 2N6543)

Tags: shemazujalica

Thursday, January 17, 2019

Unicode TCC 2

https://bellard.org/tcc/tcc-doc.html

https://bellard.org/

https://bellard.org/tcc/changelog.html

https://sathyasays.com/2013/02/08/salute-to-fabrice-bellard/

https://tinycc-devel.nongnu.narkive.com/kQoPYDTv/building-unicode-applications-with-tcc-in-windows



Amongst others, he’s created/led
  • A 4G LTE base station running entirely in software on a standard PC.
  • A new ASN1 compiler generating small and efficient C code.
  • A PC emulator in Javascript: how much time takes your browser to boot Linux ?
  • 2700 billion decimal digits of Pi computed with a desktop computer.
  • Analog and Digital TV (DVB-T) signal generation by displaying an image on a PC display.
  • QEMU is a generic machine emulator and virtualizer.
  • FFMPEG, the Open Source Multimedia System. I launched this project in year 2000 and led it during several years.
  • TCC is a tiny but complete ISOC99 C compiler which enables you to use C as scripting language. TCC has its roots in the OTCC project. The TCCBOOT boot loader demonstrate the speed of TCC by compiling and launching a Linux kernel in less than 15 seconds.
  • QEmacs (for Quick Emacs) is an emacs clone I began to learn Unicode rendering algorithms, text buffers manipulation and XML/HTML/CSS parsing.
  • OTCC is a very small self-compiling compiler for a subset of C I wrote to win the 2001 edition of the International Obfuscated C Contest.
  • TinyGL: a Small, Free and Fast Subset of OpenGL.
  • An online Scientific Web Calculator.
  • Pi formulas, algorithms and computations.
  • tiny C program to print the biggest known prime number.

Building Unicode applications with TCC in Windows

Building Unicode applications with TCC in Windows.
(too old to reply)
James Russell Moore
5 years ago
Permalink
Hello, I have a small utility which makes use of wide characters in
Windows. It's written using _TCHAR though so it can be built with multibyte
characters as well.

The main() function header is written as follows:

int _tmain(int argc, _TCHAR* argv[])

Translates to "main" in a multibyte build and "wmain" in a Unicode build,
but TCC seems to expect a main() function instead of a wmain() one so it
can't produce Unicode builds (I tried with a mob build as well).

Is is expected or is there something wrong? Would it be possible to make a
modification to enable wmain() to be an entry point as well as main()?

Attached to this email is a small test case.

Thanks for your time anyway.
YX Hao
5 years ago
Permalink
I think TCC hasn't implemented this.
...
Maybe you can take a look at:
win32\lib\crt1.c
win32\lib\wincrt1.c
Attached to this email is a small test case.
Thanks for your time anyway.
Daniel Glöckner
5 years ago
Permalink
Post by YX Hao
Post by James Russell Moore
Is is expected or is there something wrong? Would it be possible to make a
modification to enable wmain() to be an entry point as well as main()?
win32\lib\crt1.c
In crt1.c declare main and wmain as weak.
In _start call __getmainargs/main if main and __wgetmainargs/wmain
if !main.

I wonder if this works when linking to static libraries like libfl
(from GNU flex) that contain a main function.

Daniel
YX Hao
5 years ago
Permalink
Something more, on windows use a Unicode console environment is not convenient. It's not the default. You may need change the setting times, up and down.
You really want to pass any Unicode argv? Usually there are functions for wide chars can be used.
...
Carlos Montiers
5 years ago
Permalink
Look these code adapted from my current develop of bg tool (
http://consolesoft.com/p/bg ):

#define UNICODE

#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
#include <ctype.h>

#undef putchar
#undef putwchar
#undef isxdigit
#undef iswxdigit
#define putchar(c) fputc(c, stdout)
#define putwchar(c) fputwc(c, stdout)
#define isxdigit(d) _isctype(d, _HEX)
#define iswxdigit(d) iswctype(d, _HEX)

#ifdef UNICODE
#define strtoul wcstoul
#define _strupr _wcsupr
#define strcmp wcscmp
#define atol _wtol
#define _isctype iswctype
#define fputc fputwc
#define ReadConsoleInput ReadConsoleInputW
#define PlaySound PlaySoundW
#else
#define ReadConsoleInput ReadConsoleInputA
#define PlaySound PlaySoundA
#endif



typedef struct {
int newmode;
} _startupinfo;

void __wgetmainargs(int *_Argc, wchar_t *** _Argv, wchar_t *** _Env,
int _DoWildCard, _startupinfo * _StartInfo);
void __getmainargs(int *_Argc, char ***_Argv, char ***_Env,
int _DoWildCard, _startupinfo * _StartInfo);

int my_main(int argc, TCHAR* argv[]);


void _start(void)
{
int argc;
TCHAR **argv;
TCHAR **env;

int ret;

_startupinfo start_info = { 0 };
#ifdef UNICODE
__wgetmainargs(&argc, &argv, &env, 0, &start_info);
#else
__getmainargs(&argc, &argv, &env, 0, &start_info);
#endif

ret = my_main(argc, argv);
exit(ret);
}

int my_main(int argc, TCHAR* argv[])
{

return 0;

}

for printf:
these:
printf("Hello %s\n", argv[0]);
using unicode you need use replace with this:
wprintf(L"Hello %ls\n", argv[0]);
...
James Russell Moore
5 years ago
Permalink
Post by Daniel Glöckner
In crt1.c declare main and wmain as weak.
In _start call __getmainargs/main if main and __wgetmainargs/wmain
if !main.
I searched around for weak symbols because I didn't know about them,
thanks. I tried to declare them as weak but it seems not to be working (in
Windows maybe?). I tried placing the __attribute__((weak)) before the
semicolon and before the return type of the functions, in any case errors
were shown about the missing main or wmain function depending on the
setting. GCC also allows for a pragma but I think that's not implemented in
TCC.
Post by Daniel Glöckner
Something more, on windows use a Unicode console environment is not
convenient. It's not the default. You may need change the setting times, up
and down.
You really want to pass any Unicode argv? Usually there are functions for
wide chars can be used.
In a Unicode setting I know how long a character is, I can iterate through
the characters of a string in the same way as if they were simple chars. If
not using Unicode the characters may use more than 1 byte, so it's more
complicated to know their length. I could interpret char to be in UTF-8 to
be UTF-8 too I guess as in Linux, but in Windows things seem to get more
complicated with code pages and the like. Think for example about creating
a name of a file with Unicode characters or output an echo of the command
line.
Post by Daniel Glöckner
Look these code adapted from my current develop of bg tool
Thanks, that works with TCC without any modification, overriding the _start
routine works fine for Unicode builds but it'd have to be conditional in
the program to allow for interoperability with other compilers.
YX Hao
5 years ago
Permalink
Hi,
...
Try:
Findstr /s /n /r /c:"[^a-z]main[^a-z]" *.c

You will see the related codes for linking stage, together with the crt codes.
You known what linking does, you get the points.

I think it needs _start/_wstart pairs and linking process.
I searched gcc and ld codes to see how it could be made, but didn't get it.
...
So you need it.
Look these code adapted from my current develop of bg tool
Thanks, that works with TCC without any modification, overriding the _start
routine works fine for Unicode builds but it'd have to be conditional in the
program to allow for interoperability with other compilers.
Some one experienced, like grischka, may be interested to implement this capability for TCC.

Regards.

SOURCE TEXT>

https://tinycc-devel.nongnu.narkive.com/kQoPYDTv/building-unicode-applications-with-tcc-in-windows