Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

INTERFACING WITH C

Status
Not open for further replies.

aibelectronics

New Member
I want to write a program in C. This program is to enable one put on/off devices between certain periods of the day. Say for example, I want the PC to put on a device from 7:00PM to 7:00AM.

Does anyone have anything concreted on this? I eagerly await your response!
 
upand_at_them said:
I think most DOS programs are written in BASIC (which you can get fro free), but you can surely get a C compiler that'll produce a DOS exe.

Some free C compilers can be found here: https://www.thefreecountry.com/compilers/cpp.shtml

A BASIC interpreter was included as part of DOS, originally GWBASIC, then later QBASIC - but the compiler Quick BASIC was always a chargeable product.

So relatively few DOS programs were written in BASIC, most were either C or PASCAL, in order to give EXE files - although there are a fair number of BAS files that run under the interpreters, but it's a fairly poor way to distribute programs.

You can download free copies of the Borland Turbo C and Turbo Pascal from the Borland website - these are excellent tools, and they compile a great deal faster than the Microsoft offerings (the Turbo name is really true!).
 
I thought QBasic came with every version of DOS?

Perhaps MS released it to the public domain? I've seen it for free download lots of places on the 'net.

Mike
 
upand_at_them said:
I thought QBasic came with every version of DOS?

The earlier DOS versions supplied GWBASIC (Gee Whizz BASIC?), QBASIC appeared very much later - possibly around DOS 5 ?.

I think the very earliest DOS's used an even older version, with part of the interpreter in ROM in the computer? - but that's back before my PC days!.

Perhaps MS released it to the public domain? I've seen it for free download lots of places on the 'net.

You can download it from Microsoft, and it's often included in a directory on Windows CD's - but this might have stopped with XP?.
 
If you're running DOS it's very easy to control the parallel port in BASIC; it's the OUT command. For C, I dunno. MS Visual C probably lets you compile a DOS app, but I have no experience with this.

You haven't mentioned the circuit that's going to be connected to the PC. Are you using the serial port or parallel port?

Mike
 
Just some questions on your project. DOS is not a multi-tasking environment. So if you run your program, it means your whole PC is doing nothing but checking for start/end times. Sounds like a waste of a whole PC.

On the other hand, parallel port interfacing in DOS is easy.
A search in google gave
http://www.geocities.com/gear996/sub/parallel.html

Now, to find out the system time, see
**broken link removed**
 
It's not multi-tasking? Now how does one handle that? Anyway out?
The project is a Security system, an infra-red controllled alarm. Now I don't want it to be activated during the day time, only at night, when any movement around the protected/guarded area is likely going to be suspicious.

Thanks for the link! I'm sure it'll prove useful. :)
 
Why can't you use a microcontroller with a Real Time Clock? I've seen RTCs with PIC claiming 5 seconds per month accuracy (in a temperature-stable environment, correcting for crystal error).

Mike
 
aibelectronics said:
It's not multi-tasking? Now how does one handle that? Anyway out?

Why would you want it to be multitasking anyway?. Assuming you DO?, you can easily implement your own simple system with timer interrupts.

The project is a Security system, an infra-red controllled alarm. Now I don't want it to be activated during the day time, only at night, when any movement around the protected/guarded area is likely going to be suspicious.

It sounds like a VERY simple project to do, and presuming you can code in C (and if not, why are you asking for C code?) there should be no problem (personally I don't do C, I'd use Turbo Pascal to do it, but either would be perfectly fine).

A PC has a hardware battery backed clock, all you need to do is check the time from that in a continuous loop, if it's within your required parameters then enable the alarm, if it's outside the parameters then disable the alarm.

I seem to recall you can call a BIOS 'interrupt' to read the time from the clock?, you should be able to find details on old C programming sites. It's all a LONG!!! time ago now :lol:

However, a PC seems like massive overkill for the job!.
 
LINUX!!!!!!!!!!

perfect for this

and equally use PYTHON
and equally use CRON to service it
 
micro-controllers with RTC'S? I don't know much about either.
where can I get a micro-controller/RTC tutorial for "dummies"?
Could using RTC be easier than using the computer's time?
 
aibelectronics said:
micro-controllers with RTC'S? I don't know much about either.
where can I get a micro-controller/RTC tutorial for "dummies"?
Could using RTC be easier than using the computer's time?

The PC already has an RTC inside it, usually a Motorola one as I recall?, no doubt someone will produce the number of it - but I seem to remember digits something like 16818?.
 
Well, first there's the overhead of learning to program and use a microcontroller if you don't know how already. It's not that difficult, but it will take some time. And money for a programmer and compiler.

PICs like the 16F628 can create an RTC easily enough by connecting a watch crystal (32kHz) to Timer1. Are there any tutorials in C?...I dunno.

Mike
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top