Conversion speed information from NMEA message on speed pulse

hello, I'm going to investigate the operation of the ublox NEO-M8L module on the ship, so I'm going to connect the module to the ship's log (which transmits the NMEA message). How do I have to convert a NMEA message so that the module can receive speed in the same way as from a car with a CAN bus? In order to convert the message, I intend to use the Arduino Mega 2560 board. I can read the NMEA message easily from the board, but how can I change this message on the speed pulse ?? What should the code look like?

so that the module can receive speed in the same way as from a car with a CAN bus

Use exactly the same protocol as the automobile would, on the CAN bus, but substitute the NMEA derived velocity.

1.) Find the total distance between the current and previous lat/long pairs
2.) Find the total time difference between the current and previous NMEA sentence timestamps
3.) speed = distance traveled / total time difference

Power_Broker:
1.) Find the total distance between the current and previous lat/long pairs
2.) Find the total time difference between the current and previous NMEA sentence timestamps
3.) speed = distance traveled / total time difference

Yes, that will give the speed between two points, but will not give the current speed of the vessel. The OP needs to actually tell us which speed he is interested in.

Paul

Of course I need the current speed of the ship because I want to position in real time.
How can I use PWM to convert speed from a NMEA message on a wheel-tick?
I can measure the wheel-tick value for several speeds in the car by connecting the INS system to the CAN bus. But how can I translate this to PWM in Arduino ??

Looks like you need to accumulate velocity and time from this message:NMEA message

Paul

Yes, I know, but how can I change the speed from this message on the wheel-tick using PWM?

how can I change the speed from this message on the wheel-tick using PWM?

I have no idea what this means.

Please try to explain much more clearly, exactly what you want to do.

KonradS:
Yes, I know, but how can I change the speed from this message on the wheel-tick using PWM?

That message gives you the current VELOCITY, not the SPEED! You have to average the velocity for a specific TIME in order to get speed.

Paul

That makes no sense. To most people, velocity and speed are the same thing.

To physicists, velocity is a vector, with some direction, while speed is the magnitude of the velocity vector.

“speed” is always given with a time value. MPH or KPH or feet per second. OR in the maritime and aircraft, knots per time unit.

Paul

Yes, of course measurement units must be specified.

Is it possible the OP just wants to convert the velocity to some value to make a servo move, or step a stepper motor? Why is it so hard to write what the plan is?

Paul

KonradS:
Yes, I know, but how can I change the speed from this message on the wheel-tick using PWM?

Just for our clarification, when you say "PWM" do you mean

  1. varying the duty cycle of a waveform (constant frequency)

OR

  1. varying the number of pulses per seconds

based on the speed information from the NMEA message?

either case I think a little bit more information would be needed to help you:

given a speed 'x', for (1), what would be the corresponding duty cycle and/or
in the case of (2), the number of pulses per second + width of 1 pulse

I need a code that will convert the speed given in the NMEA message (sent to the Arduino board) on the wheel-tick (speed pulse = pulses per second). Automotive INS modules normally receive a wheel-note from the car, from the CAN bus. I want to receive a wheel-tick from NMEA, so I need to convert the speed data grom VTG sentences to wheel-tick.

KonradS:
I need a code that will convert the speed given in the NMEA message (sent to the Arduino board) on the wheel-tick (speed pulse = pulses per second). Automotive INS modules normally receive a wheel-note from the car, from the CAN bus. I want to receive a wheel-tick from NMEA, so I need to convert the speed data grom VTG sentences to wheel-tick.

you really need to work on your communication skills!

we get what you want to do but you are not giving us the right information!!!

your answered without really answering!

sure we get that you want ‘pulses per second’ but you did not bother to give the information requested! … which was

sherzaad:
given a speed ‘x’, the number of pulses per second + width of 1 pulse

anyway since you seem bent on giving a genetic answer every time, we can only give you a generic help,

in this case you could try something like this:

(assumption: YOU have already pulled out the speed data out or the NMEA message)

#define PulseON 100 //100us pulsewidth
#define SpeedToPulse 10 //Assumtion 10 pulses per knot (NMEA speed unit)
#define PERIOD 1000000UL //1s (1e6us)


unsigned long oldtime, timing;

void setup() {                
  // you initialisation
  //
  
  //initialise digital pin
  pinMode(pulsePin, OUTPUT);  
  digitalWrite(pulsePin, LOW);  

}
   /////////////////////////////
   
void loop() {
float speed;
unsigned long pulses, pulse_period, pulseOFF;
  
	/*
	....
	NMEA message read and decoded
	*/
  
    pulses = ((unsigned long) speed)*SpeedToPulse;
	
    pulse_period = PERIOD/pulses;
	
	pulseOFF = pulse_period - PulseON;
	
	for(uint8_t i=0; i<pulses;++i){
		digitalWrite(pulsePin, HIGH);
		delayMicroseconds(PulseON);
		digitalWrite(pulsePin, LOW);
		delayMicroseconds(PulseOFF);
	}
}

there are of course less blocking solutions but since you are vague with your requirements, this is the simplest generic solution I can think of

GOOD LUCK!