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!
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!).
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?
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.
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.
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).
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!.
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?
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.