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.

How to get Hz from parrallel port.

Status
Not open for further replies.
danielsmusic said:
i know defenetly the program work at the prosesser speed but the paralell port cannot

The only place anything runs at processor speed is inside the processor, so at the VERY best only small parts of your program will ever run at that speed.

the program timing is "perfect" this time

That's an interesting comment :lol:

How are you doing the timing?, I've been writing a hardware interfacing program for many years (WinPicProg) - it took me a LONG time to find a Windows API that will give me (mostly) 1mS accuracy.

If you've got an accurate way I'll happily 'steal' it! :lol:
 
the following code is in c++
if i do a everlasting while loop

Code:
while(1)
{
i can use the Sleep() fuction
Code:
        sleep(1000); //1 second
        int howlong = 0;
        cin >> howlong;
        Sleep(howlong); //user defind
}

this should be the best way (in my knowlage) to do this sort of thing
this is to 1 ms

the full source code of outputparrallel:
Code:
#include <iostream>
#include <windows.h>
using namespace std;

void _stdcall Out32(short PortAddress, short data);

int main()
{
          cout << "type in how long to flash in milliseconds";
          int howlong = 0;
          cin >> howlong;
          howlong = howlong/2;
          while(1)
          {
                    Out32(888, 255)
                    Sleep(howlong);
                    Out32(888, 0);
                    Sleep(howlong);
          }
          return 0;
}
 
danielsmusic said:
the following code is in c++
if i do a everlasting while loop

this should be the best way (in my knowlage) to do this sort of thing
this is to 1 ms

But it only works in DOS, you can't do that under Windows - also it only gives 1mS resolution, giving your program a maximum output frequency of only 500Hz - somewhat different to the UHF radio frequencies you've been claiming?.
 
it can output up the highest freq possible from the port.
i does run on windows and even linux i have windows xp
and that is the hardest to ouput somthing to a port.
 
danielsmusic said:
it can output up the highest freq possible from the port.

But you've got a minimum 1mS delay per half cycle, so the maximum possible frequency is only 500Hz - how do you expect to get more than that with the piece of code you posted?.
 
danielsmusic said:
1ms is not the minimum you can use 0.1

As far as I'm aware the Sleep() command ONLY accepts integers, with 1 (obviously) being the minimum. All the compilers I've ever seen (or heard of) don't allow floating point numbers for functions like that.

Also, as you mentioned Windows, presumably you're running in a DOS box?, this will make a mess of your 1mS timing anyway.
 
:? you are quite new to C(++) aren't you ?

The datatype you use for the variable 'Howlong' is integer.
integers can only hold real numbers, you cannot assign 0.1 to an integer

int foo;
foo = 0.1;

would cast the number and foo would be 0, or generate a compiler error if it can't be casted.
 
forgot how hard it was to beat nigel to the punch :lol:

on a sidenote: I just noticed you're offering complete songs on a normal webpage :? ... I hope you realize what you're doing , and how easely 'they' can track you down :?
 
iv been doin c++ for 2 years
im sorry i made a mistake that code i gave you i wrote without copy and pasting
danielsgames.co.uk is going to change anyway i have never got round to it
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top