okay i added "INPUT_PULLUP" instead of just "INPUT" at Pinmode and that 
pulled every pin high, once i push the button it goes low and stays low 
until i dont push the button anymore. but the problem is, i can start the 
machine once and the connected pin is for example serialreceive.bit-28 and 
the next time it is serialreceive.bit-20 so not the same 

Am Samstag, 8. Juli 2017 00:24:39 UTC+2 schrieb Sag ich Dir nich:
>
> okay, so i tried the old program but with 250 miliseconds and Baudrate of 
> 115200 and have connected a button to a pin and ground. When i push the 
> button, the signal gets recognized but it flickers on and off. This is also 
> only ment for Buttons to start/stop a program and maybe some switches for 
> special stuff, which does not require realtime (for example flood or switch 
> for toolchanger to let the machine know if the pneumatic piston is in the 
> correct position)
>
> Am Freitag, 7. Juli 2017 12:53:22 UTC+2 schrieb Schooner:
>>
>>
>> On 06/07/17 22:02, Sag ich Dir nich wrote:
>>
>> the Code they came up with is: 
>>
>> void setup() {
>>   for (uint8_t pin = 14; pin < 14 + 32; pin++) {
>>     pinMode(pin, INPUT_PULLUP);
>>   }
>>   Serial.begin(250000);
>> }
>>
>> void loop() {
>>   static unsigned long iterations;
>>   static unsigned long lastSecond;
>>   unsigned long topLoop = millis();
>>   iterations++;
>>   uint8_t pin = 14;
>>   for (uint8_t bytes = 0; bytes < 4; bytes++) {
>>     uint8_t eightBits = 0;
>>     for (uint8_t bits = 0; bits < 8; bits++) {
>>       bitWrite(eightBits, bits, !digitalRead(pin++)); // HIGH als 0, LOW 
>> als 1
>>     }
>>     if (eightBits < 16) {
>>       Serial.write('0');
>>     }
>>     Serial.print(eightBits, HEX);
>>   }
>>   Serial.println();
>>   if (topLoop - lastSecond >= 1000) {
>>     Serial.print(iterations);
>>     Serial.println(F(" / second"));
>>     iterations = 0;
>>     lastSecond = topLoop;
>>   }
>> }
>>
>> the Arduino will spit out over 2000 times every second
>>
>>
>> That is fine for a theoretical figure from an arduino which has nothing 
>> to do except output data, 
>> data which it has no idea as to whether it will be received or not.
>>
>> On a computer running an operating system, with a realtime pre-emptive 
>> scheduling kernel, running an existing realtime application
>> (machinekit), where the receipt of the data is important, things are 
>> quite different
>>
>> Look at your servo thread speed and work out how many times the realtime 
>> thread polls a second .
>> 1,000,000 / 100,000 ? 
>> 10 ?
>>
>> This component is userspace and the kernel priority given to it will not 
>> get anywhere near the realtime modules.
>> Add to that, this is not serial, but UART, serial over USB, USB timing 
>> being uncertain at best and not guaranteed,
>> which is why it is not used for anything in realtime.
>>
>> I would suggest you increase the baud rate to 115200 and the wait time to 
>> .25 seconds and try that.
>>
>> The other option is to check what is sent to see if it has changed from 
>> the last packet, if not , either don't send it,
>> or skip over it at the receiving end.
>> That will prevent constantly updating pins which don't need changing, 
>> saving processor time and preventing pulsing.
>>
>> Am Donnerstag, 6. Juli 2017 09:56:42 UTC+2 schrieb Schooner: 
>>>
>>>
>>> On 05/07/17 22:01, Sag ich Dir nich wrote: 
>>> > how responsive were your inputs? mine take a couple of seconds, 
>>> > sometimes dont even get recognized and sometimes are recognized but i 
>>> > have not pushed the button 
>>> > 
>>> It was just an example of how to transfer the data from arduino to HAL, 
>>> plenty of scope for tuning. 
>>>
>>> The baud rate is probably set at B9600 
>>> You can increase this up to B115200 with the arduino, just make sure 
>>> both ends are set the same. 
>>>
>>> Then look at the delay() in the arduino script and usleep() in the 
>>> component 
>>> They are both set to quite long periods (1 sec - ie 1000ms and 1000000us 
>>> respectively) 
>>>
>>> This could be reduced without impacting performance too much, depends 
>>> what else is going on. 
>>>
>>> Time to start learning what the code does I'm afraid.  The arduino IDE 
>>> is a pretty easy way to get into C / C++. 
>>>
>> -- 
>> website: http://www.machinekit.io blog: http://blog.machinekit.io 
>> github: https://github.com/machinekit
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Machinekit" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected].
>> Visit this group at https://groups.google.com/group/machinekit.
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>>

-- 
website: http://www.machinekit.io blog: http://blog.machinekit.io github: 
https://github.com/machinekit
--- 
You received this message because you are subscribed to the Google Groups 
"Machinekit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at https://groups.google.com/group/machinekit.
For more options, visit https://groups.google.com/d/optout.

Reply via email to