Thanks Salem, I understand now :)
Type: Posts; User: ak47
Thanks Salem, I understand now :)
Also in your example, it is assumed that the motor first moves clockwise then it moves counter- clockwise, But that may not always be the case. What if the motor is instructed to rotate...
I see, so for the opposite direction i just need to subtract?
bool counterclockwise_crossed(uint16_t initial, uint16_t previous, uint16_t current)
{
if (initial > previous)
{
...
Okay coming back to my logical bug, How do i remove the first rotation bug? Any idea?
pMotor->ptrFCL->qep.MechTheta is a float. This is a normalized value and varies from 0.0 to 1.0 only.
0 being the 0th Mechanical degree and 1.0 being the 360th mechanical degree. To avoid the...
Hello Experts,
I am trying to write a function that counts the number of rotations of a motor. The function calculates the number of rotations based on the mechanical angle. The mechanical angle is...
Thanks for the code , the controller which we am using has a hardware floating point unit , so we am thinking the accumulated errors will not be much..
Hello Experts,
I am trying to write a quick function to calculate the RMS values, without using any blocking calls(mainly loops)
This is what I have so far, it is not optimized for speed for which...
Thanks Salem, this is very elegant :)
Will try it and let you know!
16618
Hello Experts,
I came up with this state machine for one of my embedded projects, looking at a few reference programs online. And was wondering if someone could verify it for me, I am not able to...
Hello Matt,
I got an alternative to that.
#include <stdio.h>
#include <stdlib.h>
int get_time_diff(int*,int*);
int main()
{
int old_time[] = {22,00,00,15,7,2015}; ...
Hello Everyone,
I need some help writing a function which calculates the difference between any two given times.
I have made a rough skeleton of the function but need some help filling it. ...
Hello everyone,
I am confused with formatting large decimal numbers.
Please consider the following example
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define pi...
Hello Everyone :)
Please bear with me if this sounds a bit silly.
I would like to know if there is a way(piece of code/snippet in C) by which
at any time during a program execution by pressing a...
Let me give you an example of the buffer array.
buffer_array[] = "operation1 error code NULL \n operation2 error code 10 \n operation3 error code STOP";
or
buffer_array[] = "operation1 error...
Thanks for the quick reply Mr. grumpy.
I see,yes the %*s is much simpler to use rather than to use another array to store the discarded data (buffer_to_discard),however sscanf() is only useful if i...
Hello every one,
I was looking for ways to stop using scanf() as it has got the obvious bug when handling string data,
and also sometimes it holds the inputs coming from stdin ,and i have to use...
Hey guys,i solved the issue,it was in my Writefile statement.
if(!WriteFile(hSerial,cmd,strlen(cmd),&dwBytesRead, NULL))
I removed the strlen() rightly pointed out by Salem and replaced it...
unsigned char cmd[10] = "\0";
unsigned char rzBuff[10] = "\0";
i thought that ,that %d would effect the next byte too,but it did not.I confirmed it by changing it to %c(1 byte) and...
Actually my array is 10 bytes.
unsigned char cmd[10] = "\0";
unsigned char rzBuff[10] = "\0";
Originally cmd[] was 12 bytes long,i needed to confirm that data after cmd[9] was being looped...
Hello everyone,
I have a function that creates a custom protocol for transmission of data to a serial port.
The function is below:
void calc()
{
/*cmd array and num integer are global*/
...
Hello Tim,
Thank you for you reply.
There did make a mistake in my earlier post.
I am passing just b not *b in my function.I realized i had made that mistake after reading your post.
Anyway i...
Hello everyone,
I am having trouble figuring out where the bug is in my code.
I have two functions which are used to access a serial port.
When i combine then it works correctly ,but when i split...
Hello Mr. grupmy,
*'k',in this case is a simple counter with a range of 0 to 257,changed its name y the way :).
*And i have been meaning to ask,when is it useful to use system() calls and when is...